Payment providers
Polar revenue attribution with CrispStats
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.
Updated
Set up CrispStats on Polar
- 01
Step 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.
- 02
Step 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:writeis optional: with it, sales show up the moment they happen. A personal access token (polar_pat_) is refused.orders:readrefunds:readorganizations:readwebhooks:write (optional: sales the moment they happen) - 03
Step 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.
- 04
Step 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’smetadata. Call it in the click handler, not on your server: the id belongs to the browser that asks.checkout.js// In the browser, before you send the visitor to checkoutconst visitorId = await crispstats.id();// On your server, when you create the checkoutconst checkout = await polar.checkouts. create( {// ...your productsmetadata: { 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.
CrispStats on Polar
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 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 and limits
- 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_idis 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 or expansion. Polar stays the source of truth for subscriptions and benefits.
- With
The docs page covers the optional steps this guide leaves out.
Setup questions. Straight answers.
What people ask before they connect it.
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.
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.
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.
CrispStats deletes its webhook endpoint in Polar and destroys the saved token. Payments already recorded stay. You can then delete the token in Polar.
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.
Not answered here? Write to hello@crispstats.com
Go further
Related
- Revenue attribution: which traffic pays
See which source, page and campaign each payment came from.
- Stripe revenue attribution
Connect Stripe to CrispStats with a restricted key and pass the visitor id at checkout, so every payment, renewal and refund is tied to the visit behind it.
- Lemon Squeezy revenue attribution
Connect Lemon Squeezy to CrispStats with an API key and pass the visitor id as custom data, so orders, renewals and refunds are tied to the visit behind them.
- Web analytics for developers
A small cookieless script with web vitals and error tracking, an npm SDK, a REST API and an MCP server, so your analytics fits the way you work.
- Revenue per visitor calculator
Enter visitors, conversion rate and average order value to get revenue per visitor, monthly revenue, and what a 10% improvement is worth.
Guides
- The best marketing and revenue attribution tools for SaaS and indie makers
Twelve marketing attribution tools that tie payments to traffic sources, compared by payment providers read, price and limits.
- The best SaaS analytics tools, layer by layer: website, product and revenue
Twelve SaaS analytics tools sorted into the three layers a SaaS needs, with prices, limits, a worked stack and the method behind the list.
Other integrations
Frameworks
Site builders
Ecommerce platforms
Tag managers
Your traffic, crisp and clear
One script, no cookies, and every feature from the first day. Set up takes about as long as pasting a snippet.