How to track Stripe revenue by traffic source and UTM campaign

· 7 min read · WhoPaid team

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

See which tweet, post or ad made you money.

WhoPaid links every Stripe or Dodo payment to the source that brought the buyer.