Skip to main content
Connect Stripe and PostMetric pulls your payments every 5 minutes, then credits each one to the visitor and marketing channel that produced it.

Connect Stripe

  1. Create a restricted key (rk_…) with read access to Core, Billing, Checkout and Events (under All core resources → Events).
  2. In PostMetric, open your website’s settings and paste the key under Revenue → Stripe.
PostMetric imports past payments when you connect, a few pages at a time in the background, so a large account can take a while to fill in. After that it reads your account’s Stripe Events every 5 minutes, so a payment is picked up when it succeeds, however long after the checkout started. Without Events access the sync falls back to re-reading the last 3 days of payments on every run. Refunds are synced too and are subtracted from revenue, and subscription renewals are marked as renewals. Payments in a currency other than your website’s currency are counted using the amount Stripe settled to your balance when that matches your website’s currency; otherwise they are left out of revenue totals.

How a payment finds its visitor

PostMetric checks these in order and uses the first that matches:
  1. Visitor ids in Stripe metadata. On the PaymentIntent, the subscription, or the Checkout Session that created the payment.
  2. The success page. The tracking script reports ?session_id=cs_… when the customer lands back on your site.
  3. The same customer’s earlier payment. Renewals and later purchases inherit the attribution of the customer’s first payment.
  4. The customer’s email. From postmetric("payment", { email }) or user identification.
A payment that matches none of these stays unattributed. It still counts toward revenue. 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’s metadata. In the Payment Link’s After payment tab, redirect to your site with:
The tracking script reports it and the payment is recorded immediately. This works best when the customer pays in the same browser they browsed in.

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: