# Polar revenue attribution with CrispStats

Updated 2026-11-24

Connect Polar in CrispStats with an organization access token, then put the visitor id in the checkout's metadata as crispstats_visitor_id. CrispStats imports your past orders and refunds, reads each new one back from Polar's API, and credits one-time purchases, new subscriptions, renewals and refunds to the visit that led to them.

## Steps

### 1. Open the Polar panel

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

### 2. Create an organization access token

Select **Create an access token in Polar**. In **Settings**, **Access tokens**, choose **Create token**, choose **No expiration** and tick the scopes below. `webhooks:write` is optional: with it, sales show up the moment they happen. A personal access token (`polar_pat_`) is refused.

```text
orders:read
refunds:read
organizations:read
webhooks:write   (optional: sales the moment they happen)
```

### 3. Paste the token and connect

Paste the token. CrispStats checks it with Polar and shows your organization's name. Select **Connect Polar**: the token is saved encrypted, a webhook endpoint is created when the token allows it, and the import of past orders and refunds starts.

### 4. Pass the visitor id at checkout

Call `crispstats.id()` in the browser before the visitor leaves for checkout, send it to your server, and put it in the checkout's `metadata`. 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, when you create the checkout
const checkout = await polar.checkouts.create({
  // ...your products
  metadata: { crispstats_visitor_id: visitorId },
});
```

## Check that it works

The Polar 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

- Polar orders by source, channel, campaign and landing page, credited to the first touch known for the customer.
- Each order read back from Polar's API before it counts as verified revenue, sorted into one-time purchases, new subscriptions and renewals.
- Refunds recorded as negative payments, dated when Polar made them, including refunds of older orders.
- Product names, and past orders and refunds imported when you connect, so revenue and [MRR](/glossary/mrr) cover your whole Polar 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 Polar

- With `webhooks:write`, Polar sends each order within seconds and CrispStats checks every 15 minutes as a safety net. Without it, CrispStats reads new orders and refunds every minute, so a sale appears within a minute.
- Polar tokens cannot be edited once made, so a token that lacks a scope is refused with the scope it needs: create a new token with it ticked.
- The order's metadata is merged over the customer's metadata, so an id on the customer also counts. The customer's `external_id` is used as your own user id when the metadata has none.
- 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). Polar stays the source of truth for subscriptions and benefits.

Full reference: [Polar in the docs](https://docs.crispstats.com/revenue/polar)

## Frequently asked questions

### Which scopes does the Polar token need?

orders:read, refunds:read and organizations:read. webhooks:write is optional and lets the webhook endpoint be created and deleted for you. The token cannot change products, checkouts or refunds, and it is never shown again.

### Are Polar renewals attributed?

Yes. A renewal takes the attribution of the same customer's earliest attributed payment, matched by a hash of the email, and an id on the customer's metadata counts for every order.

### Can I import Polar orders from before I connected?

Yes. Connecting with a token starts the import at once: every paid order and refund since your first. Orders made before the script was on your site have no visit, so they count in revenue but stay out of the source breakdowns.

### What happens when I disconnect Polar?

CrispStats deletes its webhook endpoint in Polar and destroys the saved token. Payments already recorded stay. You can then delete the token in Polar.

### Is Polar revenue attribution on every plan?

Yes. Connecting with a token, the order import and renewal attribution all work on every plan and in the 14-day free trial, because every feature is on every plan.

## Related

- [Revenue attribution: which traffic pays](/features/revenue-attribution)
- [Stripe revenue attribution](/integrations/stripe)
- [Lemon Squeezy revenue attribution](/integrations/lemon-squeezy)
- [Web analytics for developers](/for/developers)
- [Revenue per visitor calculator](/tools/revenue-per-visitor-calculator)
