Revenue attribution
Link payments to the first visit with analytics.identify().
Revenue attribution tells you which sources, campaigns, and pages bring paying customers. It links each payment to the first visit of the person who paid. There are two ways to link them: by email, and by a checkout token. You can use one or both.
Method 1: match by email
- A visitor signs up or logs in on your website.
- Your code calls
analytics.identify()with their email address. - Later, the same person pays. Your connected provider has their email on the payment.
- At the next sync, Dodolytics matches the two emails. The payment then counts for that person's first visit.
Add the call
Call analytics.identify() right after a visitor signs up
or logs in, with the email they used:
if (window.analytics) {
analytics.identify('[email protected]');
}
Use the same email that your payment provider records for the customer. Capital letters and spaces at the start or end do not matter.
Method 2: match by checkout token
Use this when visitors pay without a sign-up, or when you cannot call
identify(). Your site asks the tracking script for a
token, and puts it in the checkout's metadata with the name
dodolytics_token. When the payment syncs, Dodolytics
finds the visit that made the token.
// In the browser, when the visitor clicks your buy button:
var token = window.analytics ? analytics.checkoutToken() : null;
// Send the token to your server with the checkout request.
Then add it to the checkout on your server, or in the browser for Paddle:
| Provider | Where the token goes |
|---|---|
| Stripe Checkout | payment_intent_data[metadata][dodolytics_token] |
| Stripe PaymentIntent | metadata[dodolytics_token] |
| Polar | The checkout's metadata: { "dodolytics_token": token } |
| Paddle | customData: { dodolytics_token: token } in Paddle.js, or the transaction's custom_data |
| Dodo Payments | The checkout session's metadata: { "dodolytics_token": token } |
- Each page load gets a new token. Calls on the same page give the same token.
- Ask for the token when the visitor clicks your checkout or buy button, not while the page loads. The script must record the page view first, so that the token has a visit to link to.
- Dodolytics keeps a token for 30 days. A payment that comes later is not matched by its token.
- When a payment matches both ways, the email match is used, because it can find an earlier first visit.
- The token links the payment to that visitor's first visit on the same day. Dodolytics does not know visits from other days, unless the visitor is also identified.
Not supported: Lemon Squeezy (its API does not return checkout data with an order), and Stripe subscriptions (Stripe does not copy the metadata to the charges of a subscription). Use the email match for these.
Read the results
Open Revenue and find Revenue by first visit. Choose Source, Campaign, Country, Device, or Landing page.
- Per visitor: the revenue of a source divided by its visitors in the same period.
- Lifetime value: for the customers in a row, the average of all their payments ever, in the currency of the chart.
- Not matched: payments that Dodolytics could not link to a visit.
Revenue on the other reports
After the first payment matches a visitor, the Sources, Referrers, Campaigns, Countries, Devices, and Landing Pages reports get two more columns: Revenue and Per visitor. A payment counts for the row of the customer's first visit. You can sort by these columns, and they are in the CSV export.
- The columns show one currency, the one with the largest total in the period. The line under the table names it.
- A report filter also filters the revenue: a payment counts when the customer's first visit matches the filter.
A payment can match later, for example when the customer identifies after they pay. The next sync links it.
Privacy
- Dodolytics never finds an email by itself. Only your own
identify()call sends one. - The email is stored encrypted, for this website only.
- For an identified visitor, visits on different days are linked. All other visitors stay anonymous and are recognized for one day only.
- A checkout token is a random code for one page load. The script keeps it in memory only. Dodolytics stores a one-way code of it with the visit, for 30 days.
- Tell your users about this in your own privacy policy.
- To remove a person's data on request, use Settings › Erase an identified visitor. Their visits become anonymous again. Their payments stay, because they are your provider's records.
First and repeat payments in the Revenue report
do not need identify(). They use the email on the
payment only.
Related articles
Still need help? Ask on our feedback board or see all topics.