SupalyticsSupalyticsBeta

Revenue attribution connects your Stripe payments to visitor traffic sources, letting you see which channels drive actual revenue—not just visits.

How It Works

  1. Supalytics tracker loads on your site and assigns a visitorId
  2. You pass this visitorId to Stripe when creating a payment
  3. Supalytics syncs Stripe charges and matches them with pageview data
  4. Revenue appears in your dashboard, attributed to the visitor's traffic source

Setup

1. Connect Stripe

Go to Settings → Integrations and connect your Stripe account with a restricted API key.

Create a restricted key in Stripe Dashboard with only Charges: Read permission.

If you click this link, it will automatically select the permission. Make sure you are on the right project, you can see that in sidebar in the left.

2. Pass visitor_id to Stripe

The Supalytics script exposes window.supalytics.visitorId on your site. You need to send this to your backend and include it in Stripe metadata.

Client-side: Capture the visitor ID

// Get the visitor ID from the Supalytics tracker
const visitorId = window.supalytics?.visitorId || null;

// Send it to your backend with the checkout request
const response = await fetch('/api/create-checkout', {
  method: 'POST',
  body: JSON.stringify({
    // ... your checkout data
    supalyticsVisitorId: visitorId,
  }),
});

Using optional chaining (?.) handles cases where the tracker hasn't loaded yet or is blocked by ad blockers. It's safe to omit the visitor ID—those payments just won't be attributed.

Server-side: Add to Stripe metadata

For subscription checkouts (most common), add it to the session metadata:

const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  // ... your checkout config
  metadata: {
    supalytics_visitor_id: supalyticsVisitorId, // from request body
  },
});

For one-time payments, add it to payment_intent_data.metadata:

const session = await stripe.checkout.sessions.create({
  mode: 'payment',
  // ... your checkout config
  payment_intent_data: {
    metadata: {
      supalytics_visitor_id: supalyticsVisitorId,
    },
  },
});

For direct payment intents (without Checkout):

const paymentIntent = await stripe.paymentIntents.create({
  amount: 1000,
  currency: 'usd',
  metadata: {
    supalytics_visitor_id: supalyticsVisitorId,
  },
});

3. Verify It's Working

After a successful payment, check that the metadata is being sent correctly:

  1. Go to your Stripe Dashboard → Payments
  2. Click on a recent transaction
  3. Scroll down to the Metadata section on the right
  4. You should see supalytics_visitor_id with the visitor ID value

Stripe metadata verification

4. View Revenue Data

Revenue data syncs automatically when you load your dashboard. You'll see:

  • Revenue breakdown by country, source, UTM parameters
  • Revenue bars overlaid on visitor breakdown cards
  • Hover tooltips showing visitors, revenue, and revenue per visitor

Privacy

Revenue attribution is fully GDPR compliant:

  • visitor_id is a daily-rotating hash of IP + User Agent + domain
  • No cookies required
  • No personal data stored
  • Only charge amounts are synced, not customer details

Sync Behavior

  • Syncs run lazily when you load the dashboard
  • Minimum 10 minutes between syncs
  • Fetches charges from last 30 days on first sync
  • Subsequent syncs only fetch new charges since last sync

On this page

Revenue Attribution - Supalytics