Stripe Checkout revenue attribution
Pass XPmetric visitor IDs into Stripe Checkout metadata to attribute revenue to traffic sources.
Connect Stripe in Settings → Integrations, then pass XPmetric visitor IDs into Checkout metadata so payments tie back to first-touch channel, referrer, and landing page.
Prerequisites
- Install p.js on your site.
- Connect Stripe with a restricted API key in Settings → Integrations → Stripe.
- Create Checkout sessions server-side (Stripe API) so you can set metadata.
Static Payment Links cannot carry per-visitor metadata.
Pass visitor IDs
p.js exposes:
window.xpmetric.v— visitor hashwindow.xpmetric.s— session id
Add both to Checkout Session metadata:
// Pass XPmetric visitor IDs into Stripe Checkout metadata
const visitorId = window.xpmetric?.v || "";
const sessionId = window.xpmetric?.s || "";
const session = await stripe.checkout.sessions.create({
// ...your existing checkout options
subscription_data: {
metadata: {
xpm_visitor_id: visitorId,
xpm_session_id: sessionId,
},
},
payment_intent_data: {
metadata: {
xpm_visitor_id: visitorId,
xpm_session_id: sessionId,
},
},
});XPmetric's Stripe sync reads xpm_visitor_id and xpm_session_id from subscription invoice metadata and PaymentIntent metadata automatically.
Verify
- Complete a test checkout on your site.
- Open Channels or Revenue breakdown on the site dashboard — the payment should appear with attribution once sync runs (~5 min, or click Sync Now in Settings).
Related
- Polar attribution — same metadata pattern for Polar
- Payments API — record payments from any provider