See which post, newsletter or launch brought each Polar order.
For creators who sell templates, downloads and licences through Polar. Virling ties each order to the visit that brought the buyer, so you can tell the post that sold your template from the one that only got attention. Open source under AGPL, hosted or self-hosted.
You publish a template, post about it in a few places, mention it in a newsletter, and orders start to arrive in Polar. Each one names the buyer and the amount, but not where they came from. Virling records the visit on your sales page, passes a visitor ID into checkout, and reads it back from the order.
What you get
- Every order joined to the visits before it. You see the channel, source, campaign and landing page. By default the credit goes to the latest visit in the last 90 days that was not Direct, so a reader who found your template in a newsletter and typed your address a week later still counts for the newsletter.
- Posts and issues compared by money. Make one tracked link per post, issue or bio. The Campaign tab shows each one by name with its clicks, visitors and revenue.
- Launch days measured in sales. Log a launch under Launches to see the visitors, new customers and revenue of that day and the day after. Those figures count all traffic on the two days, so use tracked links to tell the places apart.
- Checkout links that need no code. Links on
buy.polar.shget the visitor ID from the script, which suits a sales page built without a server. - Refunds taken off. New refunds update the order they belong to, and a pending refund is read again once it settles.
- Renewals kept with the first channel. If a licence or a library of downloads is sold as a subscription, an order with billing reason
subscription_cycleis a renewal and keeps the channel of that customer's first payment.
Set it up
- Add the site. Click + Add a site and enter the domain of your sales page, such as
yourtemplates.com, and its timezone. - Install the script. Paste the tag before
</head>on every page, including the ones that hold your buy buttons. Leave cookieless mode off, since checkout needs the visitor ID. - Connect Polar. In your Polar organization's settings, create an Organization Access Token with
orders:readandrefunds:read, plussubscriptions:readso Retention can tell who still pays. No other scopes are needed. Paste it into Virling; it starts withpolar_oat_. Orders from the last 90 days are imported on the first run, then new orders every minute. There is no webhook to set up. - Link your buy buttons. A checkout link needs no code: keep it as a normal
<a href>tobuy.polar.sh. The script addsreference_id=<visitor ID>unless it is already there, and Polar stores it in the order's metadata. For a checkout you create on your server, setvirling_vidinmetadatafrom the cookie of the same name. - Share tracked links. Point each one at your sales page, not straight at checkout. A newsletter link counts as Email when its page has
?utm_medium=email.
<!-- A checkout link: no code needed -->
<a href="https://buy.polar.sh/YOUR_CHECKOUT_LINK">Get the template</a>
// A checkout you create on your server
const checkout = await polar.checkouts.create({
products: ["PRODUCT_ID"],
success_url: "https://yourtemplates.com/thanks",
metadata: { virling_vid: req.cookies.virling_vid },
});
// Send the customer to checkout.urlTo check it, open your sales page from a link tagged ?utm_source=test&utm_medium=test, make a test purchase and wait for the next sync. The payment should show the test source instead of Unattributed.
Each step of the checkout is explained in Polar UTM tracking, and the Polar integration page covers the token and what is imported. To see what you keep from a sale before you price a template, use the Polar fee calculator. Other providers are on revenue attribution for digital products.
Where a Polar order can be linked
| What you do | Can the sale be linked? | Why, or what it takes |
|---|---|---|
| Post a link to your sales page | Yes | The visit is recorded, then the buyer clicks through to buy.polar.sh with the visitor ID |
| Post a checkout link, or put it in a bio | No | Nothing adds reference_id to a link outside your pages |
| Link to your sales page from an email | Yes | It counts as Email when the link has utm_medium=email |
| Link to checkout from an email | No | The order carries no visitor ID |
| Put a checkout link on your own site | Yes | A normal <a href> on a page that runs the script. No code |
Put a checkout link with your own reference_id on your site | Not by the script | It leaves your value alone. A virling_ custom field on the link still works |
| Create the checkout on your server | Yes, if you pass the ID | virling_ in metadata, from the cookie |
| Publish a marketplace listing | Only if it leads to your site and the buyer pays through your Polar checkout | An order the marketplace bills itself is not in Polar, so it is not in Virling |
Orders that cannot be linked stay in your total as Unattributed. A first-time buyer who reads your post on a phone and buys on a laptop has a different visitor ID on each, so that order is credited only to visits on the laptop. A later order by the same Polar customer keeps the channel of the first one, if that was linked.
Refunds in a made-up example
Invented numbers, to show what refunds do to a ranking. A designer sells a $40 template through Polar, and 5 of the Communities orders were refunded in full. Sales counts every order, and revenue is after refunds:
| Made up | Visitors | Sales | Revenue | Revenue per visitor |
|---|---|---|---|---|
| Communities | 1,000 | 20 | $600 | $0.60 |
| Organic search | 500 | 8 | $320 | $0.64 |
| 200 | 6 | $240 | $1.20 |
Before refunds, Communities made $800, or $0.80 per visitor, and stood above Organic search. After the 5 refunds it made $600, or $0.60, and falls just below it. It still brought the most money, so the question is why a quarter of those buyers asked for it back: the post may promise something the template does not do. Email brought the least in total and the most per visitor, with no refunds.
What to know
- A checkout link opened from an email, a QR code or another site carries no visitor ID. The order still counts toward revenue, as Unattributed.
- If a checkout link already has its own
reference_id, the script leaves it alone, so that order carries no visitor ID. - Orders from the 90-day import made before the script was on your site are Unattributed. Older orders are not imported.
- Free downloads, one-time orders of $0, are not imported. Virling counts paid orders.
- Virling does not read which product an order was for. Give each product its own page and tracked links.
Open source
Virling is open source under AGPLv3, and the code is on GitHub. Use the hosted service, or self-host it as one binary with every feature. In a load test on 2026-10-31, in a container limited to one vCPU and 1 GB of RAM, it ingested 100,000 pageviews at 2,829 a second with none failed and a p99 of 34 ms, and used 157 MB of memory after the ingest.
Frequently asked questions
How do I see Polar digital product sales by traffic source?
Add the Virling script to your sales page, connect Polar with an organization access token and keep your checkout links as normal links on that page. Each order is then credited to a visit before it, with its channel, source, campaign and landing page.
Do Polar checkout links need code to be attributed?
No. Keep each buy.polar.sh link as a normal link on a page that runs the Virling script. The script adds reference_id with the visitor ID, unless the link already has one, and Polar stores it in the order's metadata, where Virling reads it. Only a checkout you create on your server needs virling_vid set in its metadata.
Can I put a Polar checkout link straight in a newsletter or bio?
You can, but that order shows as Unattributed. A checkout link opened from an email, a QR code or another site carries no visitor ID. Send readers to your sales page and let them click through to checkout from there.
Can Virling show revenue for each product I sell on Polar?
No. Virling does not read which product an order was for. If you sell several products on one site, give each its own page and tracked links, and compare them by landing page and campaign.
Are Polar refunds taken off?
Yes. New refunds update the order they belong to, and a pending refund is read again once it settles.
Can Virling match a Polar order to a visitor by email?
No. Email matching works for Stripe, Shopify and WooCommerce payments only. A Polar order needs the visitor ID, which a normal checkout link on a page that runs the script carries, or which you set in the metadata of a checkout you create on your server.
Full guides: Sell digital products, Polar in the docs, Link checkout to visits and Tracked links.