Stripe analytics: connect your payments to traffic sources
Stripe shows who paid; your analytics shows who visited. How to connect the two so every Stripe payment is credited to its source, campaign and landing page.
Keen Analytics team2 min read
Stripe's dashboard is excellent at money: MRR, churn, failed payments. What it can't tell you is where your customers came from. Your web analytics knows the opposite. Connecting them answers the question both are missing: which traffic turns into Stripe revenue?
Step 1: add the tracking script
Keen Analytics needs to see the visit first. Add one tag to every page, or install the keen-analytics npm package for React, Next.js, Vue and other frameworks:
<script defer src="https://c.getkeen.cc/js/a.js" data-site="your-site-id"></script>Step 2: connect Stripe with a read-only key
In Settings → Integrations, connect Stripe with a restricted, read-only API key. Keen Analytics reads payments; it can't create charges or change anything in your account. It stores amounts, currencies, products and a hashed customer reference, never names, emails or card details.
Step 3: pass the visit to the checkout
This is the step that makes attribution work. How you do it depends on how you sell:
- Stripe Payment Links (
buy.stripe.comlinks on your pages): nothing to do. The script adds the visit reference to the link automatically. - Checkout sessions you create on your server: read the reference in the browser with
keen.ref()and send it to your server, then pass it to Stripe asclient_reference_id(or asmetadata.keen_refif you already use that field).
// In the browser, before starting checkout
import { ref } from "keen-analytics";
const keenRef = await ref(); // null if tracking is blocked
// On your server
const session = await stripe.checkout.sessions.create({
mode: "subscription",
line_items: [{ price: "price_123", quantity: 1 }],
client_reference_id: keenRef ?? undefined,
success_url: "https://example.com/thanks",
});Step 4: read revenue by source
Payments are credited to the visit that first brought the customer (why first touch). On the Revenue page you'll see revenue, new customers, MRR and refunds, broken down by source, campaign, landing page, country and device, plus revenue per visitor for each.
What about subscriptions and renewals?
Renewals are credited to the same first visit as the original purchase, so a channel that brings long-lived subscribers keeps earning credit month after month. That's usually what you want: it rewards channels that bring good customers, not just many.
Apps: RevenueCat
If you sell in-app subscriptions, connect RevenueCat instead (it covers the App Store, Google Play and web). Pass the visit reference as the keen_ref subscriber attribute when a user arrives from your website, and app purchases appear next to web revenue.
Ready to try it? Start on the free plan and follow the install guide; revenue attribution is part of Pro, which you can try free for 14 days.
Keep reading
- Revenue attribution for SaaS: see which channels bring paying customersVisitors and signups don't pay the bills. Here's how to see which channels bring customers who actually pay.
- Cookieless analytics: how to measure your website without cookiesHow analytics can count visitors without storing anything on their device, and what you actually give up.
- UTM tracking guide: tag your links to measure revenue, not clicksWhich UTM parameters to use, naming rules that keep reports clean, and how to tie campaigns to revenue.