Attribute revenue to visitors

Attribution is what connects a payment to the visit that caused it. With it, a sale in your conversions list shows the source, campaign, or referrer that brought the customer in, so you can tell which marketing actually pays for itself.

Snow links a customer in your payment provider to a Snow visitor. The reliable way is to pass the visitor id yourself, which you wire up once with one of the two methods below. Snow also checks a few other signals on its own.

Both methods rely on the visitor id that the Snow tracker assigns. You pass that id to Stripe (at checkout) or to Snow (server-side); Snow uses it to tie the resulting payment back to the right visit.

For every checkout, subscription, invoice, order and payment your provider sends, Snow links the customer to a visitor with the first of these that applies:

  1. Checkout metadata: an sa_visitor_id in the checkout, subscription, invoice, order or payment metadata (Stripe, Polar, Dodo Payments), or a Polar Checkout Link reference_id. This is the method set up below.
  2. Identify API: a stripe_customer_id sent with the Identify API.
  3. Checkout reference: a Stripe client_reference_id or a Dodo Payments metadata.reference_id holding the visitor id, alone or as <visitor id>.<session id> or <visitor id>_<session id>. Snow only takes it if that visitor visited your site in the 180 days before the payment.
  4. Session match: an sa_session_id in the metadata without a visitor id, when exactly one visitor had that session.
  5. Email match: the customer's email equals the email you sent with Identify for exactly one person on your site. That person's devices all link.

Every match is exact. When a signal is ambiguous, such as an email shared by two people, Snow links nothing rather than guess. The Trials list shows which method linked each customer.

Methods 3 to 5 are rolling out. Until they're switched on, Snow checks them but only methods 1 and 2 create links. Once on, they apply to checkouts, subscriptions and payments from then on; older history keeps the links it has.

Snow only matches data you already send it: the visitor id, your identify calls and the customer details from your provider. If your site only tracks visitors who consent, only those visitors can be linked.

Get the visitor id

On the client, the tracker exposes the current visitor's id:

const visitorId = window.sa.getVisitorId();

You'll pass this id along when you create the Stripe Checkout Session, or send it to the Identify API from your server.

Choose a method

When you create the Stripe Checkout Session, read the visitor id from window.sa.getVisitorId() and pass it into the session's metadata (and the subscription's metadata) under the key sa_visitor_id.

const visitorId = window.sa.getVisitorId();

// Send the visitor id to your server, which creates the Checkout Session.
await fetch("/create-checkout-session", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ visitorId }),
});

Then, on your server, include it when you create the session:

const session = await stripe.checkout.sessions.create({
  mode: "subscription", // or "payment"
  line_items: [{ price: "price_123", quantity: 1 }],
  success_url: "https://example.com/success",
  cancel_url: "https://example.com/cancel",

  // Links the payment back to the Snow visitor:
  metadata: { sa_visitor_id: visitorId },

  // For subscriptions, also stamp it on the subscription itself. Snow reads
  // it there too, so a subscription created without Checkout still links:
  subscription_data: {
    metadata: { sa_visitor_id: visitorId },
  },
});

Snow does not inject sa_visitor_id for you. You add it yourself when you create the Checkout Session. That's the step that makes attribution work.

Requirements and limits

Attribution mode

Cross-session Stripe attribution requires attribution mode. In this mode the visitor id is stable across sessions, so a payment that happens later can still be tied back to the original visit. New sites default to cookieless mode, so you must choose attribution mode and deploy the regenerated snippet first.

Cookieless mode caveat

In cookieless mode, the visitor id rotates daily and lives only server-side, so there's no stable id to hand to Stripe. That means cross-session Stripe attribution isn't available in cookieless mode.

If linking visitors to revenue matters to you, switch the site to attribution mode and replace the snippet already deployed on your website.

See it land

Once attribution is wired up, new payments in your conversions list and new trials in your Trials list will show the visit and source behind them. For more on identifying visitors generally, see Identify users.

On this page