Get started

Revenue attribution

Polar

Attribute Polar orders and subscriptions to the visits that earned them.

1. Create a key

In Settings → Revenue, choose Polar and paste:

Organization access token: Polar → Settings → Developers → New token, with the orders:read scope.

Organization ID: Optional for organization tokens.

Calmstats only reads payments. It can't charge, refund or change anything in your account.

2. Add the webhook

Copy the webhook endpoint shown in Settings → Revenue and add it in Polar with these events:

order.paid, order.refunded, order.updated

Webhooks make payments appear right away. Without them, payments still arrive with the daily sync.

3. Pass the visitor to checkout

JavaScript
const visitorId = window.calmstats?.getVisitorId();

// Server: create the checkout with the visitor from the browser
const checkout = await polar.checkouts.create({
  products: [productId],
  metadata: { calmstats_visitor_id: visitorId },
});