# Dodo Payments revenue attribution with CrispStats

Updated 2026-11-24

Connect Dodo Payments in CrispStats by pasting an API key, then put the visitor id in the payment's or subscription's metadata as crispstats_visitor_id. CrispStats imports your past payments and refunds, reads each new one back from Dodo's API, and credits payments, subscription charges, refunds and lost disputes to the visit that led to them.

## Steps

### 1. Open the Dodo Payments panel

The CrispStats script must already run on your site. Open the site's **Settings**, select **Integrations**, choose **Connect a payment provider** and pick Dodo Payments. You need permission to manage the site's settings.

### 2. Create an API key in Dodo Payments

Select **Open API keys in Dodo Payments**, then open **Developer**, **API keys** and choose **Create new key**. Give it the permissions below and leave everything else at **None**. **Webhooks: Write** is optional: with it, sales show up the moment they happen. Copy the key: it starts with `dodo_live_`, or `dodo_test_` in test mode.

```text
Payments: Read
Refunds: Read
Subscriptions: Read
Products: Read
Webhooks: Write   (optional: sales the moment they happen)
```

### 3. Paste the key and connect

Paste the key and select **Connect Dodo Payments**. CrispStats checks it with Dodo, saves it encrypted, creates a webhook when the key allows it, and starts importing past payments and refunds.

### 4. Pass the visitor id at checkout

Call `crispstats.id()` in the browser before the visitor leaves for checkout and add it to the `metadata` of the payment, subscription or checkout session you create. Call it in the click handler, not on your server: the id belongs to the browser that asks.

`checkout.js`

```js
// In the browser, before you send the visitor to checkout
const visitorId = await crispstats.id();

// On your server, in the body of the payment or subscription you create
const body = {
  // ...your product cart and customer
  metadata: { crispstats_visitor_id: visitorId },
};
```

## Check that it works

The Dodo Payments row in **Settings**, **Integrations** shows **Connected**, whether it is live, and when it last updated. Make a purchase from a page with the script: it appears under **Payments** on the Revenue screen with the source of that visit. If the key stops working or loses a permission, the row says so and names the way out.

## What you get

- Dodo Payments revenue by source, channel, campaign and landing page, credited to the first touch known for the customer.
- Each payment read back from Dodo's API before it counts as verified revenue: one-time payments, first subscription charges and renewals kept apart.
- Refunds, and disputes the business lost or accepted, recorded as negative payments that never exceed the payment.
- Past payments and refunds imported when you connect, so revenue and [MRR](/glossary/mrr) cover your whole history.
- Customer email stored only hashed and masked; renewals without a visitor id take the attribution of the customer's earliest attributed payment.

## Notes for Dodo Payments

- With **Webhooks: Write**, Dodo sends each payment within seconds and CrispStats checks every 15 minutes as a safety net. Without it, CrispStats reads new payments and refunds every 2 minutes, so a sale appears within 2 minutes. A lost dispute without the webhook can take up to a day.
- Dodo payments are stored without a product name. The payment's metadata is merged over the customer's metadata, so an id on the customer also counts.
- A test key connects in test mode once you choose **Connect in test mode**. Test payments show with a **Test** tag on the Revenue screen and are kept out of revenue, MRR and every total.
- A payment without a visitor id is still recorded and counted in revenue, MRR and every total. It is left out of the source, campaign and channel breakdowns rather than filed under Direct.
- Connections made earlier with a webhook you added by hand keep working, but cannot import history or verify payments. Connect again with a key to add both.
- CrispStats does not calculate [churn](/glossary/churn-rate) or [expansion](/glossary/expansion-revenue). Dodo Payments, as merchant of record, stays the source of truth for billing, tax and payouts.

Full reference: [Dodo Payments in the docs](https://docs.crispstats.com/revenue/dodo)

## Frequently asked questions

### Which permissions does the Dodo Payments key need?

Read on Payments, Refunds, Subscriptions and Products. Write on Webhooks is optional and lets the webhook be created and deleted for you. Leave Customers and everything else at None. The key never moves money and is never shown again.

### Are subscription renewals attributed?

Yes. A renewal carries the subscription's metadata, and one without a visitor id takes the attribution of the same customer's earliest attributed payment, matched by a hash of the email.

### Can I import Dodo Payments revenue from before I connected?

Yes. Connecting with a key starts the import at once: every succeeded payment and refund since your first.

### What happens when I disconnect Dodo Payments?

CrispStats deletes its webhook in Dodo Payments and destroys the saved key. Payments already recorded stay in your reports.

### Is Dodo Payments revenue attribution on every plan?

Yes, history import included. Every feature is on every plan and in the 14-day free trial, and payments are kept on every plan.

## Related

- [Revenue attribution: which traffic pays](/features/revenue-attribution)
- [First touch vs last touch attribution](/blog/revenue-attribution-first-touch-vs-last-touch)
- [Creem revenue attribution](/integrations/creem)
- [Web analytics for indie hackers](/for/indie-hackers)
- [Revenue per visitor calculator](/tools/revenue-per-visitor-calculator)
