Blog

How to Connect Stripe to Your Analytics and See Revenue by Source (2026)

June 24, 2026Piqo Analytics5 min read

Most analytics tools tell you where your traffic comes from. Almost none tell you where your money comes from.

You can see that 5,000 people came from Google and 2,000 from Twitter — but which group actually paid? Without that, you're optimizing for clicks instead of revenue.

This guide shows you how to connect Stripe to your analytics and see revenue by source: which channel, campaign, or referrer drove each paying customer — including subscriptions and renewals.

Quick answer: Capture a first-party visitor ID when someone lands on your site, pass that ID to Stripe as checkout metadata, then let your analytics match the paid order back to the visitor's original traffic source — all server-side, so ad blockers and cookie limits can't lose it.


Why Google Analytics can't really show this

GA can show "revenue" if you wire up e-commerce events — but it falls short for most SaaS and digital businesses:

The fix is to attribute revenue from the payment itself — on your server, where it can't be blocked.


What "revenue by source" actually means

It's a simple join:

The traffic source of a visitor's first visit → linked to → the real money they later paid you.

So instead of "Twitter sent 2,000 visits," you get "Twitter brought in $4,300 across 18 paying customers." That's the number that should drive your marketing budget.


How it works (the mechanism)

Three steps tie a sale back to a source:

  1. Capture — When a visitor lands, your analytics stores a first-party visitor ID on your own domain.
  2. Pass — At checkout, you attach that ID to the Stripe payment as metadata.
  3. Match — When Stripe confirms the payment, your analytics links that ID to the visitor's first-visit source (Google, UTM campaign, referrer, etc.) and records the revenue.

The important part: step 3 happens server-side, on a confirmed payment — not in a browser that may have blocked or forgotten everything.


Step-by-step: set it up with Stripe

Here's the full setup. (Examples use Piqo, but the pattern is the same anywhere.)

1. Install your analytics tracker

Add the lightweight script to your site so it sets a first-party visitor ID:

<script defer src="https://piqo.app/piqo.js" data-site="YOUR_SITE_KEY"></script>

2. Read the visitor ID at checkout

When a customer starts checkout, read the first-party cookie on your server:

// Your server, when creating the Stripe Checkout Session
const piqoVisitorId = req.cookies['piqo_visitor']; // 16-char first-party ID

3. Pass it to Stripe as metadata

Attach it to the Checkout Session so the payment carries the source link:

const session = await stripe.checkout.sessions.create({
  mode: 'subscription', // or 'payment'
  line_items: [{ price: 'price_123', quantity: 1 }],
  success_url: 'https://yoursite.com/thanks',
  metadata: {
    piqo_visitor_id: piqoVisitorId, // <-- the one line that connects revenue to source
  },
});

4. Connect your Stripe key in your analytics

In Piqo, open Settings → Revenue → Stripe and paste a restricted Stripe API key. Piqo reads your paid payments and matches them to sources automatically.

5. Read your revenue-by-source report

Now your dashboard shows channels, campaigns, and referrers ranked by revenue, not just visits.


Don't forget recurring revenue

For subscription businesses, the first payment is only the start. A good setup also captures renewals — every monthly or yearly charge — and credits them to the original source, so you can see the true lifetime value by channel.


Cookieless and privacy-friendly by design

Because the visitor ID is first-party and the matching happens server-side, this approach:

Want the deep dive? Read What Is Cookieless Analytics? and How Ad Blockers Break Your Analytics.


Frequently asked questions

Does revenue-by-source tracking work without cookies?

Yes. It uses a first-party ID (not a third-party cookie) and confirms the sale server-side from Stripe, so it isn't lost to browser restrictions.

Does it track subscription renewals?

It should. Look for a tool that records renewals from Stripe invoices and attributes them to the original source — not just the first checkout.

What if a customer pays without my visitor ID?

The revenue is still recorded; it just shows as Direct until a source can be matched. The more reliably you pass the ID at checkout, the more revenue gets attributed.

Is a restricted Stripe key safe to use?

Yes — use a read-only restricted key with Charges/Invoices read access. It can't move money or change anything.

Does this work with Paddle, Polar, Creem, or Dodo too?

Yes. The same metadata pattern works across Stripe, Paddle, Polar, Creem, and Dodo Payments.


Conclusion

Traffic numbers feel good. Revenue numbers grow the business. Once you can see which sources actually make you money, you stop pouring budget into channels that bring clicks but no customers.

The setup is one line of metadata plus a read-only key:

First-party visitor ID → Stripe metadata → server-side match = revenue by source.

Want it working in 10 minutes? Try Piqo free — privacy-first analytics with built-in Stripe revenue attribution, subscriptions and renewals included.


Further reading: What Is Cookieless Analytics? · How Ad Blockers Break Your Analytics · Cookieless Affiliate Tracking

‹ All posts

Start tracking in 30 seconds.

Get started for free

10,000 events per month free · no credit card · cancel anytime