Revenue attribution
Connect Stripe, Lemon Squeezy or Polar and see revenue by every source.
Connect a payment provider on the site's Settings page, under Payments. Each provider gets its own webhook URL:
https://pathrail.io/api/webhooks/stripe/<site id> https://pathrail.io/api/webhooks/lemonsqueezy/<site id> https://pathrail.io/api/webhooks/polar/<site id>
Paste the webhook's signing secret back into Pathrail. Every webhook is verified with it.
| Stripe | checkout.session.completed, invoice.paid, charge.refunded |
| Lemon Squeezy | order_created, subscription_payment_success, order_refunded |
| Polar | order.paid, order.refunded |
How a payment finds its visitor
In order, Pathrail uses the first of these that matches:
- The visitor id the checkout carried. The script adds it to Stripe Payment Links (client_reference_id), Lemon Squeezy checkout links and Polar checkout links for you.
- A visitor already linked to the same customer id.
- A visitor linked to the same email with identify.
- An earlier payment from the same customer or email.
If you create checkouts on your server, pass the visitor id yourself. In the browser it is window.pathrail.visitorId.
// Stripe Checkout Session, server side
stripe.checkout.sessions.create({
...,
client_reference_id: visitorIdFromTheBrowser,
// or: metadata: { pathrail_visitor_id: visitorIdFromTheBrowser }
})For Lemon Squeezy use checkout_data.custom.pathrail_visitor_id; for Polar use metadata.pathrail_visitor_id.
First and last touch
Each payment keeps both: where the person first came from across all their linked visits, and the last visit before they paid. Revenue tables default to first touch; the Revenue page shows both side by side. Renewals keep the original customer's sources, so lifetime value by source is exact.
Amounts are recorded in the currency the provider reports. Pathrail doesn't convert between currencies.