Skip to content
Payment providers

Stripe Checkout analytics and attribution

2 min read · Updated · By the Reveata team

Short answerAdd the Reveata visitor and session ids to the metadata of each Stripe Checkout Session your server creates. When Stripe reports the payment, Reveata reads the ids and credits the money to the exact visit that started the checkout.

Stripe Checkout (opens in a new tab) is the hosted payment page your server opens with a Checkout Session. Because your server creates the session, it is also the best place to say which visitor is paying. Two metadata keys are enough.

What you get

  • Each Checkout payment credited to the visit that led to it, under your attribution model (first touch, last touch or last non-direct touch).
  • In subscription mode, the ids are applied to the first invoice and to the subscription, so every renewal keeps the source of the first payment. You only send the ids once.
  • In payment mode, they are applied to the PaymentIntent the session creates.
  • Revenue, customers and revenue per visitor on every report, from channels to landing pages.

The keys Reveata reads

Where on the session Keys
metadata reveata_visitor_id, reveata_session_id, optional reveata_user_id
client_reference_id dt_<visitorId>_<sessionId>

Reveata reads these when the checkout.session.completed or checkout.session.async_payment_succeeded webhook arrives, and also during scheduled imports. Stripe's own notes on metadata are in Stripe's metadata documentation (opens in a new tab).

How to set it up

  1. Connect Stripe in Settings → Payments with a restricted key or Connect with Stripe (Stripe revenue analytics).
  2. Get the ids. In the browser, window.reveata.metadata() returns { reveata_visitor_id, reveata_session_id }. On your server, read the first-party cookies _dt_v and _dt_s and keep the part before the first dot.
  3. Put them in the session's metadata when you create it:
js
const session = await stripe.checkout.sessions.create({
  mode: 'subscription',
  line_items: [{ price: priceId, quantity: 1 }],
  success_url: 'https://example.com/thanks',
  metadata: {
    reveata_visitor_id: body.reveata_visitor_id,
    reveata_session_id: body.reveata_session_id,
  },
});

The Stripe Checkout guide has the cookie parser for Node.js, PHP, Python, Ruby and Go, and a Next.js helper (readTrackerIds from @reveata/next/server).

Limits worth knowing

  • Cookieless mode keeps no ids in the browser, so there is nothing to send. Payments then match by the buyer's email for visitors you identify.
  • The session cookie expires after 30 idle minutes. The visitor id alone is enough to match.
  • A free, fully discounted checkout is not a payment and does not appear.
  • Unmatched payments are retried every hour for 90 days, so an identify call after the purchase still links them.

Frequently asked questions

Do I need both the visitor id and the session id?

No. The visitor id alone matches the payment. The session id helps pin the exact visit, which matters for last-touch attribution.

Can I use client_reference_id instead of metadata?

Yes, if you write it in the dt_<visitorId>_<sessionId> format. A client_reference_id in any other format is treated as your own reference and ignored by Reveata.

Will a replayed webhook add the payment twice?

No. Payments are keyed on their Stripe ids, so replays and later imports update the same payment.

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
IntegrationStripe revenue analytics by traffic sourceReveata reads your Stripe payments, invoices, subscriptions, refunds and lost disputes through a read-only connection, then credits each payment to the visit that brought the buyer, so revenue sits next to traffic in every report.IntegrationStripe subscription analytics by acquisition channelWith Stripe connected, Reveata reads your subscriptions and invoices to show MRR and its movements, and groups paying subscriptions by the first-touch channel of each customer, so you can see which channels bring subscribers who stay.IntegrationDodo Payments analytics with revenue by sourceReveata connects to Dodo Payments with an API key and a webhook you add in Dodo, imports payments, refunds, disputes and subscriptions, and credits each payment to a visit through reveata_visitor_id in the checkout or payment metadata.IntegrationPolar analytics with revenue attributionReveata imports Polar orders, refunds and subscriptions and receives new ones through a Polar webhook. Put the Reveata visitor id in the checkout metadata, which Polar copies onto orders and subscriptions, and each sale is credited to the visit that led to it.IntegrationRevenue attribution for custom billing with the Payments APIIf your provider is not one Reveata connects to, or you bill customers yourself, post each payment to the Reveata Payments API with a website key. Include the visitor id, a user id or an email, and the payment is attributed like any connected provider's.IntegrationStripe Elements and PaymentIntent analyticsWhen your server creates a Stripe PaymentIntent for Elements, the Payment Element or a mobile app, put reveata_visitor_id and reveata_session_id in its metadata. Reveata reads them when payment_intent.succeeded arrives and credits the payment to that visit.