How-to

How to Track Polar Revenue by Traffic Source

Connect Polar.sh orders to the visits, sources and UTM campaigns behind them: checkout links with no code, the Checkout API, webhooks, renewals and refunds.

Last reviewed 10 min readBy the SuprAnalytics team at SuprApps

Illustration: a Polar checkout link tagged with the visitor id, then a visit from Reddit, a paid order and $29 of revenue credited to Reddit

Polar shows you every order. It doesn't show you which post, search or newsletter sent the customer. To see that, a visitor id from your website analytics has to ride along with the checkout and come back with the order.

With Polar this is shorter than with most payment providers, because checkout links can carry the id without any code. This guide covers both ways to pay with Polar, the webhook that reports each order, and where attribution can't find a source.

The quick answer

To attribute Polar revenue to traffic sources:

  1. Record each visit and its source with an analytics script on every page.
  2. Carry the visitor id into checkout. Polar checkout links get it automatically; Checkout API sessions take it as metadata.
  3. Add a Polar webhook for order.paid, order.updated and order.refunded.
  4. Each paid order is matched to the visitor, and your attribution model picks which of their visits gets the credit.

Why Polar alone can't tell you where customers came from

Polar knows the order: the product, the amounts, the customer and their email, and the subscription it belongs to. It also keeps metadata. A checkout link even accepts utm_source, utm_medium and utm_campaign in its URL and attaches them to the checkout session (Polar: checkout links (Polar documentation, opens in a new tab)).

Those tags describe the link that was clicked, not the visit before it. If a customer read your post on Reddit, came back two days later through Google and clicked the same buy button, the tags on that button are the same either way. The referrer, the landing page and the earlier visits live in your website analytics, which has never seen the order. Joining the two needs an id both sides share.

Step 1: Track website visitors and their sources

Add the SuprAnalytics script to the <head> of every page (installation guides). Each visit then records its referrer, its UTM tags, its landing page and a visitor id kept in a first-party cookie for a year. A visit with no referrer and no tags counts as Direct. The tracking parameters guide lists the tags it reads, and the Stripe guide explains sources and sessions in more depth; it all applies to Polar too.

Step 2: Carry the visitor into Polar checkout

Checkout links: nothing to add

When a visitor clicks a Polar checkout link (https://buy.polar.sh/polar_cl_…), the SuprAnalytics script adds ?reference_id= and their visitor id to the link before the browser follows it. Polar stores it with the checkout, the order comes back through the webhook, and the id names the visitor.

From the SuprAnalytics Polar checkout links guide
<a href="https://buy.polar.sh/polar_cl_XXXXXXXX">Buy now</a>
<!-- clicked: https://buy.polar.sh/polar_cl_XXXXXXXX?reference_id=6f1c… -->
  • A link that already has a reference_id is left alone, so your own ids keep working.
  • A reference_id only counts as a visitor if SuprAnalytics has seen that visitor, so your own reference ids are never mistaken for one.
  • To stop the script changing a link, add supr-polar="false" to it.

Checkout API: pass the id as metadata

If your server creates the checkout, read the supr_visitor_id cookie from the request and put it in the checkout's metadata. The webhook returns the order with that metadata.

Node.js, from the SuprAnalytics Polar Checkout API guide
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({ accessToken: process.env.POLAR_ACCESS_TOKEN });
app.post("/checkout", async (req, res) => {
  const checkout = await polar.checkouts.create({
    products: ["<product id>"],
    successUrl: "https://yourdomain.com/thanks",
    metadata: {
      supr_visitor_id: req.cookies.supr_visitor_id,
      supr_session_id: req.cookies.supr_session_id,
    },
  });
  res.redirect(303, checkout.url);
});

Runs on your server; the access token never goes in browser code. req.cookies is Express with cookie-parser. Next.js and Python versions are in the Checkout API guide.

When there's no id: customer id and email

An order without a visitor id still counts. SuprAnalytics then looks for the Polar customer id on an earlier order that was matched, then a visitor with the same email, known from an earlier payment or from the identify call your app makes at sign-up. If nothing matches, the order is revenue without a source.

Step 3: Connect the Polar webhook

The connection is one webhook endpoint per website and its secret. There's no API key to share, and past orders aren't imported: SuprAnalytics records orders from the moment the webhook is set up.

  1. Copy your webhook URL

    In SuprAnalytics, open the website's Settings → Revenue, where Polar is the default provider, and copy the URL. It looks like https://supranalytics.app/api/webhooks/polar/YOUR_WEBSITE_ID.

  2. Add an endpoint in Polar

    In Polar, open Settings → Webhooks and click Add Endpoint. Paste the URL and choose the Raw format, which sends JSON (Polar: webhook endpoints (Polar documentation, opens in a new tab)).

  3. Select three events

    Select order.paid, order.updated and order.refunded.

  4. Paste the secret

    Copy the endpoint's secret, which starts with whsec_, into Settings → Revenue with Polar selected, and save.

The Polar events SuprAnalytics handles
order.paidWhat SuprAnalytics does: Records the order once Polar has collected the money (Polar: orders (Polar documentation, opens in a new tab)). Orders not paid yet are skipped, and so are free ones.
order.updatedWhat SuprAnalytics does: Updates the stored order when it changes, such as a renewal order moving to paid.
order.refundedWhat SuprAnalytics does: Marks the order refunded, or lowers its amount for a partial refund.

What happens on every delivery

  • Signature check. Polar signs each delivery with the webhook-id, webhook-timestamp and webhook-signature headers. SuprAnalytics checks the signature against your secret and refuses a timestamp more than 5 minutes off. A wrong secret is answered with 403 "Invalid signature" and nothing is recorded. Both Polar secret formats work: the Standard Webhooks one for secrets created since 8 September 2026, and the older one (Polar: webhook delivery (Polar documentation, opens in a new tab)).
  • Retries. Polar retries a failed delivery up to 10 times with exponential backoff, and disables an endpoint after 10 failures in a row.
  • Duplicates. Each order is stored once, so a delivery that arrives twice doesn't count twice.

Step 4: Test in Polar's sandbox

Polar has a separate sandbox (Polar documentation, opens in a new tab) at sandbox.polar.sh, with its own products, tokens and webhooks. Test there; never make a real purchase just to test attribution.

  1. In the sandbox, add an endpoint for the test website's URL with the three events, and paste its secret into that website's Settings → Revenue.
  2. Open your staging site in a fresh window with a tagged link, such as ?utm_source=test&utm_medium=email&utm_campaign=attribution_check.
  3. Click your checkout link (or start your API checkout) and pay with Polar's test card, 4242 4242 4242 4242 with any future date.
  4. In Polar, open the endpoint's deliveries. The order's delivery should show status 200; where the response is shown, look for "attributed": true.
  5. In SuprAnalytics, the payment appears in the visitor's journey and the Campaign report credits attribution_check.
The response SuprAnalytics sends Polar for a recorded, matched order
{
  "received": true,
  "result": { "visitorId": "…", "attributed": true, "duplicate": false }
}

"attributed": false means the order was recorded without a source: check that the checkout carried the visitor id. A retried delivery answers "duplicate": true.

When it works, add a second endpoint in your live Polar organization for your real website, with its own secret.

The Referrer report of the demo website sorted by revenue, on a phone.
Revenue by referrer on the demo website, with payments from several providers combined.

What Polar revenue SuprAnalytics counts

How SuprAnalytics counts Polar orders
AmountHow it's counted: The order's net_amount: after discounts, before tax. Polar is the merchant of record and handles sales tax (Polar: merchant of record (Polar documentation, opens in a new tab)), so tax isn't your revenue. Orders in other currencies are converted to your website's currency with daily rates.
First orderHow it's counted: Counts toward new customers, conversion rate and revenue.
RenewalHow it's counted: An order with the billing reason subscription_cycle, subscription_update or subscription_meter_cycle. Revenue, but not a new customer. Credited to the same visitor through the subscription's or customer's metadata, or the Polar customer id of an earlier matched order.
Free orderHow it's counted: Skipped: there's no revenue to attribute.
Full refundHow it's counted: Marks the payment refunded; it drops out of revenue.
Partial refundHow it's counted: Lowers the payment by the refunded amount before tax. Polar supports partial refunds from the dashboard and its API (Polar: refunds (Polar documentation, opens in a new tab)).

So SuprAnalytics totals won't match Polar figures that include tax. Payment tracking also isn't subscription analytics: SuprAnalytics doesn't calculate MRR, ARR or churn. What it adds is where paying and renewing customers came from (subscription revenue).

First touch or last touch?

Each order keeps two visits: the visitor's first visit ever and their last visit before paying. Last touch is the default and credits the visit that converted, even a direct one. First touch credits the visit that brought them in. Change it in Settings → Revenue → Attribution model; the switch re-credits past orders too. The first-touch vs last-touch guide works through examples.

Common Polar attribution problems

Common Polar attribution problems, what causes them and what to do
No Polar orders show upLikely cause and fix: Open the endpoint's deliveries in Polar. 400 "Polar is not configured for this website" means no secret is saved for that website; 403 "Invalid signature" means the secret belongs to another endpoint, or sandbox and live are mixed up.
Orders have no sourceLikely cause and fix: The checkout carried no visitor id. Check that the script runs on the page with the checkout link, or that your server passes the metadata, and identify signed-in users before checkout.
A checkout link isn't taggedLikely cause and fix: It already has a reference_id, carries supr-polar="false", or the click happened before the script loaded. The link must be on buy.polar.sh, or on another polar.sh address with polar_cl_ in it.
Too much Direct revenueLikely cause and fix: Untagged links, apps that drop the referrer, or last touch crediting direct returns. Tag the links you share, or compare with first touch.
Revenue lower than in PolarLikely cause and fix: SuprAnalytics counts the amount before tax, lowers partial refunds and skips free orders.

More on this: Polar revenue attribution · Polar setup guide · Checkout links · How revenue attribution works · Pricing

Frequently asked questions

Can Polar show where my customers came from?

Not on its own. Polar records the order, the customer and their email, and any metadata, including a reference_id or UTM tags added to a checkout link. It doesn't see the visits before checkout, so it can't tell you that a customer first found you through a search last week.

Do Polar checkout links need any code for attribution?

No. With the SuprAnalytics script on the page, a click on a buy.polar.sh checkout link adds the visitor's id as reference_id. Polar keeps it with the order and the webhook brings it back. Checkouts your server creates through the Checkout API need the visitor id passed as metadata.

Which Polar webhook events do I need?

order.paid, order.updated and order.refunded, sent in the Raw format to your website's webhook URL. SuprAnalytics records an order once it's paid and applies refunds when they arrive.

Does SuprAnalytics count tax in Polar revenue?

No. Revenue is the order's net_amount: after discounts, before tax. Polar is the merchant of record and handles sales tax, so the tax isn't your revenue. Totals can differ from Polar figures that include tax.

Are Polar subscription renewals tracked?

Yes. Orders with the billing reasons subscription_cycle, subscription_update and subscription_meter_cycle are recorded as renewals, credited to the same visitor through the subscription's or customer's metadata or the Polar customer id of an earlier matched order. Renewals don't count as new customers. This is payment tracking, not MRR or churn.

How are Polar refunds handled?

A full refund marks the payment refunded and it drops out of revenue. A partial refund lowers the payment by the refunded amount before tax.

Can I import past Polar orders?

No. SuprAnalytics records orders from the moment the webhook is set up. Earlier orders stay in Polar.

Why do some Polar orders have no traffic source?

They couldn't be matched to a recorded visit: the checkout carried no visitor id, the customer paid from a link opened outside your site, an ad blocker hid the visits, or cookieless mode saw a later day as a new visitor. They still count in your total revenue, without a source.
All articles

See which traffic sources bring paying customers.

Connect Polar orders to your website analytics and see which visits and campaigns lead to revenue.

14-day free trial · No card required