Skip to main content
Use this setup for SaaS products where the marketing journey begins on the web and Stripe is the source of truth for payment. It links the first visit to account creation, checkout, the initial subscription, and recurring revenue.

Before you start

You need access to the product’s frontend and backend, the Stripe account used by the product, and a Stripe test environment. Decide which lifecycle event represents a new customer and whether trials or signups should also be sent as conversions.

1. Track the acquisition journey

Install web tracking before paid traffic reaches the pricing or signup pages. Verify a pageview with campaign properties, then track only the product milestones you use, such as signup completed or trial started.

2. Identify the account

After signup, identify the visitor with your stable application user ID:
datalyr.identify(user.id, {
  email: user.email,
  plan: user.plan
})
Use the same internal ID across sessions and devices when it represents the same person. Call reset() on logout or account switching so the next user’s events are not attached to the previous account.

3. Connect Stripe

Open Sources → Stripe and complete Stripe Apps OAuth for the correct account. This connection supplies the authoritative payment lifecycle; a separate manual Stripe webhook is not required for the standard integration.

4. Bridge the visitor into checkout

Call datalyr.getStripeMetadata() when checkout begins:
  • For Checkout Sessions, pass the returned client_reference_id and metadata.
  • For PaymentIntents and Subscriptions, include metadata.visitor_id when the server creates the object.
  • Supported Stripe Payment Links on buy.stripe.com can be decorated by the current Web SDK when that feature is enabled.
Create payment objects on the backend. Never expose a Stripe secret or private Datalyr credential in browser code.

5. Verify the lifecycle

Complete a Stripe test checkout and confirm the first visit, signup, checkout, and payment appear on the same customer journey. Check value, currency, Stripe customer ID, and transaction or subscription identifiers. Then test a renewal, refund, or cancellation and confirm it remains associated with that customer.

6. Configure conversions

Connect the acquisition platforms and create separate rules only for lifecycle events you intentionally optimize toward. A signup, trial, and first paid subscription answer different questions. Do not report every recurring invoice as a new-customer conversion unless that is explicitly desired.

Common problems

  • The payment is unattributed: visitor metadata was omitted when the Stripe object was created.
  • The wrong customer is attached: identity was not reset during account switching.
  • Payment Links lose attribution: the link was rendered before the SDK initialized or uses an unsupported flow.
  • New customers are overcounted: renewal invoices are included in the acquisition conversion rule.
  • Test payments are absent: the connected Stripe account or environment does not match the test.

You are done when

A new user can arrive from a tagged campaign, sign up, complete a Stripe test checkout, and generate a correctly attributed first payment. A later lifecycle event stays on the same customer without being counted as another acquisition. See Stripe revenue for Checkout Sessions, PaymentIntents, Subscriptions, and Payment Links.