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.
1Put the visitor id on the Stripe customer
Chartsy reads it from the customer record, so set it there - not on the Checkout Session. Create (or update) the customer before checkout:
const customer = await stripe.customers.create({
email: user.email,
metadata: { chartsy_visitor_id: req.cookies.chartsy_visitor_id || '' },
});2Pass that customer to Checkout
const session = await stripe.checkout.sessions.create({
customer: customer.id,
mode: 'subscription',
line_items: [{ price: 'price_...', quantity: 1 }],
success_url: 'https://example.com/billing/success',
});Existing customers, Elements and Payment Links
stripe.customers.update(customerId, { metadata: { chartsy_visitor_id } })works the same for customers you already have.- PaymentIntents or Elements instead of Checkout? Still put the id on the Customer. Metadata on the PaymentIntent isn't read.
- Payment Links can't carry it; those customers are matched by email.


