Connect Stripe
- Create a restricted key (
rk_…) with read access to Core, Billing, Checkout and Events (under All core resources → Events). - In PostMetric, open your website’s settings and paste the key under Revenue → Stripe.
How a payment finds its visitor
PostMetric checks these in order and uses the first that matches:- Visitor ids in Stripe metadata. On the PaymentIntent, the subscription, or the Checkout Session that created the payment.
- The success page. The tracking script reports
?session_id=cs_…when the customer lands back on your site. - The same customer’s earlier payment. Renewals and later purchases inherit the attribution of the customer’s first payment.
- The customer’s email. From
postmetric("payment", { email })or user identification.
Stripe Checkout (recommended)
Pass the two PostMetric cookies as Checkout Session metadata. For subscriptions, PostMetric finds the session through the subscription, so there is nothing else to add.visitorId / sessionId, and DataFast’s datafast_visitor_id / datafast_session_id, are accepted as the same keys.
PaymentIntent API
Put the same two keys in the PaymentIntent’smetadata.
Payment Links
In the Payment Link’s After payment tab, redirect to your site with:Anything else
After a successful payment, send the customer’s email from the page they land on:Avoid double counting
Each Stripe payment is stored once, by its PaymentIntent, however it is reported. If you also report payments yourself through the Payments API, connect Stripe or use the API, not both, unless you send the PaymentIntent (pi_…) or invoice (in_…) id as providerPaymentId.
If your checkout sends visitor ids in metadata, you can stop the script reading payment ids from URLs: