DATALYR

Stripe UTM tracking: carry campaigns into Checkout

Stripe does not keep UTMs on a payment by itself. Pass campaign data into Checkout Sessions and Payment Links so every Stripe payment keeps its source.

By DATALYR · · 3 min read

Contents

Where Stripe keeps campaign data

Stripe does not record the UTMs of the visit that led to a payment on its own. Payment Links accept the five UTM codes, but Stripe passes them only to your redirect URL after payment. To keep a campaign on the payment itself, put it into the Checkout Session yourself, as metadata or as a reference to the visit, when the session is created.

A reference to the visit is usually better than the raw UTMs. One visitor ID points to the whole visit, including ad click IDs and the referrer, and survives changes to your UTM taxonomy.

This guide covers Payment Links, Checkout Sessions, direct PaymentIntents and Subscriptions, and how to check that a real payment kept its source.

Checkout Sessions: metadata

When your server creates a Checkout Session, it can attach metadata: up to 50 key-value pairs, with keys up to 40 characters and values up to 500. Stripe returns that metadata in the checkout.session.completed event.

Metadata does not copy between objects automatically. To keep a campaign on the subscription and its future invoices, set subscription_data.metadata when you create the session; Stripe snapshots subscription metadata onto each invoice it creates. For one-time payments, payment_intent_data.metadata sets it on the PaymentIntent.

Raw UTMs in metadata answer 'which campaign' for one payment. They do not carry the ad click ID the ad platform needs for matching, or the earlier touches of a longer journey.

Pass one visitor ID instead

DATALYR links a Stripe payment to the web visit through a visitor ID. For Checkout Sessions, datalyr.getStripeMetadata() returns a client_reference_id to set on the session; the Web SDK also reports the session ID as the browser leaves for Stripe, so the common Checkout flow needs no extra code. For PaymentIntents and Subscriptions you create yourself, set metadata.visitor_id.

Payment Links and embeds are decorated automatically. The Web SDK adds client_reference_id to links on buy.stripe.com and to Stripe pricing tables and buy buttons on your pages.

When no visitor ID reaches Stripe, DATALYR falls back to matching the customer email to an earlier visit.

Example: coverage across checkout paths

This is a hypothetical month with 200 Stripe payments. One hundred fifty come through Checkout Sessions your server creates, 40 through Payment Links on your pricing page, and 10 through a Payment Link a sales rep pasted into an email.

The 150 sessions carry the visitor through client_reference_id or the reported session ID. The 40 Payment Links on your pages carry it in client_reference_id. The 10 emailed-link payments never passed through a tracked page, so they are matched by the customer's email instead.

That is 150 + 40 = 190 of 200 payments, or 95%, linked by ID, with the remaining 10 joined by email when that customer visited before.

Three checkout paths

1. Checkout Sessions

150 linked by ID

client_reference_id or the reported session ID.

2. Payment Links

40 linked by ID

buy.stripe.com links decorated by the SDK.

3. Emailed Payment Link

10 matched by email

No tracked page in between; joined by customer email.

Hypothetical month: 190 of 200 payments linked by ID (95%).

Verify one real payment

Open your pricing page in a private window with ?utm_source=doctest. Pay with a Stripe test card through the same code path customers use. In DATALYR, find the checkout.session.completed or payment_intent.succeeded event, check its value and currency, and confirm the visitor ID does not start with stripe_.

A stripe_ prefix means no visitor ID or matchable email reached the payment. Check which object your code creates and whether the identity field is set before the customer reaches Stripe.

Related articles.

See what really drives revenue.

Real-time attribution, analytics and conversions for every channel, campaign and ad, ready for your team and your agents.

Get started