How to track Stripe revenue by traffic source and UTM campaign
Short answerStripe does not know where your customers came from. To get revenue by traffic source, store each visitor’s source when they land, pass a visitor ID into Stripe Checkout metadata, and match the checkout.session.completed webhook back to that visitor.
Step 1: capture the source on landing
When someone lands, read the referrer and any utm_source, utm_medium and utm_campaign parameters. Save them with an anonymous visitor ID in a first-party cookie or your database.
Step 2: pass the visitor ID to Stripe
When you create a Checkout Session on your server, add the visitor ID to the session metadata. Metadata is copied onto the session and visible in webhooks.
- metadata: { visitor_id: "v_123" }
- For subscriptions, also set subscription_data.metadata so renewals carry the same ID.
Step 3: handle the webhook
Listen for checkout.session.completed (and invoice.paid for renewals). Verify the webhook signature, read the metadata, and store the amount against the visitor’s saved source.
Step 4: report revenue per source
Group stored payments by source and campaign. Divide by visitors from the same source to get revenue per visitor, which is the fairest way to compare channels.
Or skip the plumbing
WhoPaid does all four steps: the script captures sources, a small checkout change passes the visitor cookies as metadata (or the script tags Stripe Payment Links and Dodo links for you), and the Stripe or Dodo Payments webhook links each payment automatically. Tag your links with the free UTM builder.
Frequently asked questions
Can I see UTM data in the Stripe dashboard?
Only if you write it into metadata yourself. Stripe shows metadata on each payment but doesn’t aggregate revenue by source.
Does this work with Payment Links?
Payment Links accept a client_reference_id URL parameter, which you can set to the visitor ID and read back in the webhook.
What about refunds?
Listen for charge.refunded and subtract the amount from the original source so revenue stays accurate.
Keep reading
- What is revenue attribution? A plain guide for makers
- First touch vs last touch attribution (and when to use multi-touch)
- The best web analytics tools for indie makers in 2026
- Multi-touch attribution explained (with a worked example)
- Website visitor tracking: what you can (and should) track in 2026
- Revenue analytics for small businesses: the 6 numbers that matter
- Twitter (X) analytics: how to see which tweets make you money