Attribute revenue to your traffic sources
Choose your payment provider and the attribution method that fits your checkout: metadata, payment links or the customer's email.
Revenue attribution ties each payment to the visit that led to it, so every breakdown shows revenue next to visitors: which referrers, campaigns and landing pages bring paying customers.
First connect your payment provider. Then link payments to visits in one of three ways:
| Method | How | Best for |
|---|---|---|
| Checkout API | Pass datasense_visitor_id and datasense_session_id as checkout metadata. |
Checkouts you create in code. The most reliable. |
| Payment links | Send buyers back to your site with the provider's payment ID in the URL. | No-code links and hosted checkouts. |
| Customer email | Call datasense("payment", { email }) on your success page. |
Anything else: custom flows, Elements, mobile. |
Guides
- Stripe: Checkout API, PaymentIntent API, Payment Links, other methods
- Polar: Checkout API, Checkout Links, other methods
- Lemon Squeezy: Checkout API, Payment Links, other methods
- Paddle: Checkout API, Overlay Checkout, other methods
- Dodo Payments
- Any other provider
How attribution works
Datasense finds the visitor behind each payment, most exact first, and never guesses:
| Signal | Set up |
|---|---|
| The visit in the payment: checkout metadata, or a payment link the script tagged | Metadata: one line in your checkout code. Payment links: nothing. |
| The payment's ID on your success page | Nothing, if the provider redirects to your site. |
| An earlier payment by the same customer (renewals, repeat purchases) | Nothing. |
The customer's email, from datasense("identify", id, { email }) or datasense("payment", { email }) |
One line, often already there. |
- The payment is credited to the visitor's last visit with a real source in the 90 days before it, so "clicked a tweet, came back a week later by typing the URL and paid" goes to the tweet. Returning from a checkout page never counts as a source.
- In breakdowns it counts toward that visit's landing page, referrer, campaign, country and device, even when the visit was before the selected range.
- Webhooks, payment links and success pages resolve to the provider's own payment ID, so a payment is recorded once however it arrives.
- Revenue excludes tax collected by the provider.
- Settings → Revenue shows how many of the last 30 days' payments were tied to a visit, and how. Match again re-checks the rest.
- Refunds take a payment out of revenue. Revenue is shown net of refunds.
- Renewals and free trials are stored, but don't count a visitor as a new customer.
- A payment without a visit still adds to revenue, without a source.