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.
How the link is made
Section titled “How the link is made”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.
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.
-
Install the tracker so vid/sid cookies are set. See install. No cookies, no attribution.
-
Connect Stripe in the dashboard so StatsKit can read settled purchases and their metadata. Connected keys are stored encrypted and read-only.
-
Send visitors through StatsKit checkout so the vid/sid get stamped into the Stripe session metadata. See pricing tables and checkout for the
/v1/checkoutendpoint. If you build the Stripe session yourself, addstatskit_visitor_idandstatskit_session_idto itsmetadata. -
Read revenue in results. Attach a revenue custom metric to the experiment and revenue shows up per variant.
Also track revenue server-side
Section titled “Also track revenue server-side”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.