Connect your Dodo Payments account to attribute purchases, renewals, and refunds to visitor sessions. See which pages, referrers, UTM campaigns, and devices are driving your sales.
Persist mode is required for revenue attribution. It's the only way to associate a payment with a visitor, however this requires explicit consent for EU users. Learn more.
Here's an exact step-by-step tutorial on how to integrate Dodo Payments.
We'll then automatically create a webhook endpoint for your Dodo account and Visitors will begin receiving payment.succeeded and refund.succeeded events.
Without this we can't attribute transactions to real visitors. This will enable cookie-based tracking allowing you to read the visitor cookie.
YOUR_TOKEN with your project token.<script
src="https://cdn.visitors.now/v.js"
data-token="YOUR_TOKEN"
data-persist>
</script>When a Dodo event comes in we resolve the visitor through a fallback chain:
metadata.visitorFor subscriptions, we classify the first successful charge as new and subsequent successful charges as renewal.
For refunds, we track them as negative revenue.
When creating a Dodo Checkout session on your server, read the visitor cookie from the incoming request and pass it as metadata to your Dodo checkout.
import DodoPayments from "dodopayments";
import { cookies } from "next/headers";
const dodo = new DodoPayments({
bearerToken: process.env.DODO_PAYMENTS_API_KEY!,
environment: "live_mode",
});
export async function POST() {
const visitor = (await cookies()).get("visitor")?.value;
const session = await dodo.checkoutSessions.create({
product_cart: [{ product_id: "prod_xxx", quantity: 1 }],
customer: { email: "jane@example.com", name: "Jane" },
return_url: "https://example.com/success",
metadata: { visitor },
});
return Response.json({ url: session.checkout_url });
}If you can't pass the visitor cookie in every checkout (e.g. the purchase happens on a different domain), Visitors can still attribute revenue by matching the Dodo customer email to an identified visitor.
Call visitors.identify() with the user's email when they sign in:
visitors.identify({
id: "user_123",
name: "Jane Smith",
email: "jane@example.com",
// ...
})When a Dodo event comes in without visitor metadata, Visitors will look up the customer email and match it to the identified profile. This is less reliable than passing metadata directly, but acts as a useful fallback.
Learn more about identifying users.
If revenue is showing up but it's not being attributed, ensure that:
visitor cookie set by persist mode correctly.metadata when creating the checkout session.If you are doing all that and it's still not attributing correctly, contact our support team and we'll help you to diagnose the root cause.