virling Pricing Self-host Demo Changelog Agencies GitHub Start the beta
blog / 2026-10-26

How to track Stripe revenue by traffic source

By Devendra Variya, co-founder of Virling. Published 2026-10-26.

To track Stripe revenue by traffic source, give each visitor an ID, pass that ID into Stripe when they check out, and join each payment back to the visits that came before it. Stripe knows who paid and how much. It does not know which page or channel they came from.

Step 1: set a visitor ID

Your analytics script sets one first-party ID per visitor and remembers the first source: referrer, UTM tags or direct.

Step 2: send the ID to Stripe at checkout

Pick the option that matches how you sell:

  • Checkout Session: put the visitor ID in client_reference_id or in metadata when you create the session
  • Payment Link: add ?client_reference_id=<visitor id> to the link before you send the visitor to it

Now every payment carries the visitor who made it.

Step 3: read payments and join them to visits

Read payments from Stripe with a read-only key, then match each one's ID to that visitor's earlier visits. Credit one of them with a rule you keep fixed (see first touch or last touch).

Step 4: report revenue per channel

Group the joined payments by channel and divide by visitors to get revenue per visitor. That is the table that tells you where to spend time.

What goes wrong

  • Forgetting step 2: payments arrive with no visitor and fall into Direct
  • Using a different ID in the script and in checkout, so nothing matches
  • Running the script on the marketing site but not on the page that creates the checkout, so the ID never reaches Stripe

Doing it with Virling

Virling reads Stripe through a read-only key and does the join for you. The checkout snippet is in the docs, and the setup is on the Stripe integration page.

Frequently asked questions

Can Stripe show which traffic source a payment came from?

Not on its own. Stripe records the payment, not the visit. You need to pass a visitor ID into checkout and join it to your analytics.

Should I use client_reference_id or metadata?

Either works. client_reference_id is a single dedicated field, and metadata is useful when you also store other values.

Does this work with Payment Links?

Yes. Add client_reference_id as a query parameter on the link and the value is stored on the resulting Checkout Session.

The beta is open to everyone at beta.virling.com.