Skip to content

Revenue attribution with Stripe

StatsKit attributes Stripe revenue to the visitor who earned it. When a purchase completes, it links back to the exact visitor and session, which means revenue rolls up to the experiment variant or flag the visitor was exposed to.

The tracker sets two first-party cookies on the visitor:

  • statskit_visitor_id (the vid), the stable visitor identity.
  • statskit_session_id (the sid), the current session.

When the visitor starts a Stripe Checkout through StatsKit, the vid and sid are stamped into the Stripe checkout session metadata. The purchase carries that metadata all the way through Stripe, so when it settles StatsKit reads the vid/sid back off the metadata and attributes the revenue to that visitor’s journey.

Visitor vid + sid cookies
/v1/checkout stamps metadata
Stripe payment
Attributed to experiment / flag
vid and sid ride into Stripe metadata, rolling revenue back to the visitor.

Why this ties revenue to experiments and flags

Section titled “Why this ties revenue to experiments and flags”

Because assignment is deterministic on the vid, the same vid that bought is the same vid that was bucketed into a variant or evaluated against a flag. Once the purchase is attributed to that vid, its revenue is attributed to whatever the visitor was exposed to:

  • Experiments: revenue lands on the variant the visitor saw, so a price test or headline test shows revenue per variant, not just conversion counts.
  • Flags: revenue lands on the flag value the visitor was served, so you can compare revenue for visitors who had a feature on versus off.

This is what makes revenue a first-class experiment metric rather than a number you reconcile by hand.

  1. Install the tracker so vid/sid cookies are set. See install. No cookies, no attribution.

  2. Connect Stripe in the dashboard so StatsKit can read settled purchases and their metadata. Connected keys are stored encrypted and read-only.

  3. Send visitors through StatsKit checkout so the vid/sid get stamped into the Stripe session metadata. See pricing tables and checkout for the /v1/checkout endpoint. If you build the Stripe session yourself, add statskit_visitor_id and statskit_session_id to its metadata.

  4. Read revenue in results. Attach a revenue custom metric to the experiment and revenue shows up per variant.

Metadata attribution covers purchases that go through Stripe Checkout. For revenue that settles in your backend (subscription renewals, invoices, off-session charges), also emit a server event with the same unit so metrics see it. See the server revenue recipe.