Skip to main content

What this lets you do

Connect Polar to Traceten and see which AI sources drive paying customers, not just pageviews. When an order is paid, Traceten matches it back to the originating session and attributes the revenue to the correct AI source.

Before you start

  • A Traceten account with at least one site tracked.
  • A Polar organization, and permission to create access tokens on it.
  • Your Polar organization ID. It is the UUID in your organization settings.
  • The Traceten snippet installed and verified on the site your checkout runs from.
  • Workspace admin in Traceten. Connecting and disconnecting a revenue source affects the whole workspace, so only admins can do it.

Connect Polar

You connect by pasting an organization access token and your organization ID. There is no OAuth redirect, and there is no webhook to configure: Traceten creates the webhook endpoint on your Polar organization for you.
1

Create an organization access token in Polar

Open Polar → Settings → Developers and create an organization access token.Give it a name (for example, Traceten) and these scopes:Copy the token. Polar shows it once.
2

Find your organization ID

It is the UUID shown in your Polar organization settings. Traceten asks for it because a token can reach more than one organization, and revenue belongs to exactly one.
3

Paste both into Traceten

Go to app.traceten.com/dashboard, open Settings → Integrations, and choose the site your checkout runs from at the top of the page.Pick Polar from the list of payment providers, then paste the access token and the organization ID.Click Connect.
4

Confirm the connection

Polar shows as Connected, with your organization name and the last four characters of the token.Traceten stores the token encrypted. After this point it is never shown again, in the dashboard or in the API, and only those last four characters are readable back.

What Traceten does with the token

In the same request, Traceten:
  1. Reads the organization’s name, to confirm the token can see the organization you named.
  2. Reads one order, to prove the token can actually see the revenue it is being connected for.
  3. Creates a webhook endpoint on your Polar organization pointed at Traceten, subscribed to four events, in Polar’s raw payload format.
  4. Stores the token and the webhook signing secret, both encrypted.
  5. Starts importing your last 90 days of paid orders, reading newest first and stopping at the window edge. Polar’s order list has no date filter, so one page (the one straddling that boundary) is retrieved and parsed in full, including the buyer email addresses on the orders that turn out to be older than 90 days. Those orders are discarded in memory: not imported, not stored, not logged. No page beyond the boundary is requested.
You can see the endpoint Traceten created under Settings → Webhooks. These are the four events: Traceten subscribes to both order events on purpose. Which one a given Polar organization emits is not something a connect flow can find out, and one order still produces exactly one revenue row: whichever event arrives second is recognised as the same order and dropped. Subscription revenue arrives on these same order events. A Polar subscription renewal creates an order, so every renewal is attributed to the AI source that won the customer, and it feeds the per-subscription lifetime value report. Traceten does not subscribe to Polar’s subscription.* events, because the money is already on the order.

Refunds and net revenue

Your attributed revenue is net of refunds. When a refund.created event arrives, Traceten subtracts the refunded amount from the AI source the original order was attributed to.
  • The refund is dated on the day it was issued, not the day of the original order. A past day’s revenue figure never changes after the fact, and a day on which you refunded more than you took in reads as a negative number.
  • Conversion counts stay gross. A refunded order still counts as a conversion. The money is reported separately as a refunded figure beside the net one.
  • Partial refunds subtract exactly what Polar returned.
  • A cancelled subscription is not a refund. Cancelling stops future charges. The charges already paid were earned and stay in your totals, so cancelling changes no figure in Traceten. Only a refund takes money back off.

The signing secret

Traceten generates the webhook signing secret and sends it to Polar when it creates the endpoint. If you rotate it by hand in the Polar dashboard, Traceten stops accepting deliveries. Reconnect from the Traceten dashboard to provision a fresh one. Polar signs deliveries with the Standard Webhooks specification and includes a timestamp, so Traceten rejects any delivery signed more than five minutes ago.

Sandbox tokens

Polar’s sandbox is a separate service with its own tokens, and a sandbox token is indistinguishable from a live one by looking at it. Traceten always talks to Polar production, so a sandbox token simply fails to authenticate at connect. That is the intended outcome: sandbox amounts would corrupt your revenue totals.

How attribution works

When an order is paid, Polar sends a webhook to Traceten. Traceten then tries to tie the payment back to the originating session, in priority order:
  1. Checkout metadata: if you passed the visitor’s _traceten_vid cookie as traceten_visitor_id, Traceten matches it to the originating session exactly.
  2. Checkout Link redirect: if you added ?checkout_id={CHECKOUT_ID} to the Checkout Link’s Success URL, the Traceten snippet on that page reports the checkout id and Traceten matches it to the browser that completed the purchase. See below.
  3. Email hash: if the buyer’s session called traceten.identify({ email }), Traceten matches the order’s customer email (hashed, never stored) to that visitor.
  4. No match: the payment is still recorded so revenue totals stay complete, but it shows as unattributed (no AI source).
An order Polar has not marked as paid is not counted. A Polar Checkout Link never goes through your server, so there is no place to attach checkout metadata. Instead, have Polar hand the checkout id back to your own site after payment, and let the snippet do the rest.
1

Open the Checkout Link in Polar

Polar dashboard, Products → your product → Checkout Links. Edit the link you share, or create one.
2

Set the Success URL

Point it at a page on your site that has the Traceten snippet installed, and append the checkout_id parameter:
{CHECKOUT_ID} is Polar’s own template variable. Polar replaces it with the real checkout id when it redirects the buyer. Type it exactly as shown, braces included.
3

Save the link and buy something through it

Complete a real purchase. The buyer lands on your thank-you page, the snippet reads checkout_id out of the URL, and the order appears against its AI source in Revenue, usually within a minute or two.
Things worth knowing:
  • You change nothing in your code. The only edit is the Success URL in Polar.
  • Polar must be connected to Traceten. Traceten ignores a thank-you-page report for a site whose Polar organization is not connected, and does not hold it until you connect. A report can also be discarded for up to a minute after you connect.
  • The order of events does not matter. Polar’s webhook usually reaches Traceten before the buyer’s browser finishes redirecting. When that happens the order is recorded first and re-attributed the moment the browser reports in, on the original order’s own date.
  • The thank-you page must load within 30 minutes of payment. Traceten pairs a report with an order only when the two are no more than 30 minutes apart. Polar’s redirect happens straight after payment, so this only matters for a thank-you page opened again much later.
  • The thank-you page needs the snippet. If the Success URL points somewhere the snippet is not installed, nothing is reported and the order stays unattributed.
This path matches a browser, not a person. A buyer who completes checkout on their phone and opens the confirmation link on a laptop is not matched, and neither is a confirmation URL forwarded to somebody else. Checkout metadata, where you can use it, is exact.

The amount Traceten records

Traceten records the tax-inclusive total an order was charged for, matching what a Stripe charge records. Recording the ex-tax subtotal instead would make an otherwise identical Polar site read quietly smaller in the same revenue column.

Passing the visitor ID through checkout

This is the most reliable attribution path, and the only one that works for a buyer who never identified themselves on your site. Pass the visitor’s pseudonymous Traceten identifier into the checkout as metadata.
In the dashboard, open Settings → Integrations, pick Polar and click Set up with AI. It copies a prompt for your coding assistant that wires the visitor ID into your checkout. The same card shows this site’s Visitor cookie name.
The robust way to get the value is window.traceten.getVisitorId(), called client-side and forwarded to whatever creates the checkout:
If you’d rather not change your client-side request shape, read the cookie directly server-side instead:
Do not hardcode this cookie name. It is per-site and only correct on your configured domain (not on localhost). Find the real one under Sites → Settings → Cookies → Visitor cookie name.
Polar copies checkout metadata onto the order it produces, and Traceten matches it back to the AI session that produced the visit. No personal data leaves your server on this path: the cookie value is pseudonymous and is not PII.

Verify it worked

  1. Polar reads Connected in the dashboard.
  2. The import banner finishes, and the Revenue page shows historical orders.
  3. Place a real order. It appears in Revenue within a minute or two.

Troubleshooting

“Polar would not let this token read the organization’s orders.” Add the orders:read scope to the token and reconnect. “Polar would not let this token create a webhook endpoint.” Add the webhooks:write scope and reconnect. “Polar rejected the token.” Either the token is wrong, or it is a sandbox token. Traceten connects to Polar production only. Connected, but revenue is not appearing. Check the endpoint under Settings → Webhooks is still there and pointed at Traceten. If you deleted it, or rotated its secret by hand, reconnect from the Traceten dashboard. Everything shows as unattributed. Nothing is tying orders back to sessions. Either pass traceten_visitor_id through checkout, or call traceten.identify({ email }) when a visitor signs in.

Next