Attribute Stripe revenue to signups
Put the visitor id on the Stripe customer before checkout.
Before you start
Signups must already be tracked - revenue is attributed through the signup it belongs to. See Signup tracking.
Optional. With your payment provider connected and signups tracked, Chartsy already matches revenue to each signup by email - no payment code needed. This step only covers people who pay with a different email than they signed up with. See how revenue attribution works.
1Add the visitor id to your Checkout Session
Put it in the session's metadata - when the checkout completes, Chartsy copies it onto the Stripe customer, which is where revenue matching reads it:
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [{ price: 'price_...', quantity: 1 }],
success_url: 'https://example.com/billing/success',
metadata: { chartsy_visitor_id: req.cookies.chartsy_visitor_id || '' },
// mode: 'payment' also needs: customer_creation: 'always'
});Subscription checkouts always create a customer. A one-off mode: 'payment' checkout only does with customer_creation: 'always' - without a customer there's nothing to put the id on, and the session is skipped.
Payment Links: send buyers back to your site
A Payment Link can't carry the visitor id, but its success page can. In Stripe, open each Payment Link → After payment → redirect customers to a page on your site that has the Chartsy tag, ending in ?session_id={CHECKOUT_SESSION_ID}:
https://yoursite.com/thank-you?session_id={CHECKOUT_SESSION_ID}When the buyer lands, Chartsy looks up the session with your connected Stripe account and credits the purchase to the visit that brought them - even if they never signed up. It uses your existing Stripe key, with no new permission. The same URL works as the success_url of a Checkout Session, though for checkouts you create through the API, the session metadata above is still the better fit. Details on success-page matching.
Existing customers, PaymentIntents and Elements
stripe.customers.update(customerId, { metadata: { chartsy_visitor_id } })works the same for customers you already have.- PaymentIntents or Elements instead of Checkout? Put the id on the Customer -
stripe.customers.create({ metadata: { chartsy_visitor_id } })- and use that customer. Metadata on the PaymentIntent isn't read.


