Before you start
- You can add a script tag to your marketing site and your app.
- You have a Stripe test environment.
- You have decided which event marks a new customer: signup, trial start, or first payment.
The path
Most SaaS checkouts need no backend work. Steps 1 to 3 are the whole setup. Read
Bridge the visitor into Stripe to find out whether
your checkout is one of the two shapes that need one extra field.
Bridge the visitor into Stripe
Datalyr must connect the browser that clicked your ad to the Stripe customer that pays you. The SDK does this on its own for Stripe Checkout.What happens automatically
When your server creates a Checkout Session and your page sends the browser to it, the SDK reads the session ID (cs_live_… or cs_test_…) and reports it before the browser
leaves the page. The Stripe webhook then matches that session and recovers the visitor.
This covers the common shape: your backend creates the session, returns session.url or
session.id, and your page redirects. You write no extra code.
The SDK also records the customer email from your signup and checkout forms, which gives
Datalyr a second way to match the payment.
When you must set metadata.visitor_id
Two shapes stay invisible to the browser. Add the field yourself in each case.
Read the value in the browser:
A value you set always wins. Your own
client_reference_id is never overwritten.
The SDK never decorates a
checkout.stripe.com URL, because Stripe ignores these
parameters on a session that already exists. The session ID it reports at redirect
time is what carries the visitor instead.Pick the conversion event deliberately
Never send a renewal invoice through a new-customer rule. The ad platform then counts one
customer many times, and bids toward an audience that already pays you.
Verify
- Open the marketing site in a private window with
?utm_source=stripetest. - Sign up with a test email address.
- Complete a Stripe test checkout.
- Open Users and find the account.
- Confirm the pre-signup pageviews sit on the same profile.
- Open Conversions and confirm
utm_sourcereadsstripetest. - Trigger a test renewal and confirm it does not create a second acquisition.
When it doesn’t work
Next
- Stripe revenue: every webhook and its Datalyr event name.
- Identity: how the email bridge rescues an unattributed payment.
- Subscriptions: trials, renewals, and cancellations.