LemonSqueezy UTM tracking: which channel brought each order
By Devendra Variya, co-founder of Virling. Published 2026-11-18, updated 2026-11-25.
To see which channel brought each LemonSqueezy order, pass a visitor ID into checkout as custom data, catch it in a webhook, and join it to the visits that came before. With Virling, checkout links on STORE.lemonsqueezy.com get the ID from the script with no code, custom checkouts set it in the browser or in checkout_data.custom on the server, and Virling registers the webhook when you connect. Each order then shows the channel, page and campaign behind it.
Lemon Squeezy stops processing payments on March 31, 2027. See moving to Stripe Managed Payments without losing attribution.
Pick the row that matches how you sell:
| How you sell | What to do | Code needed |
|---|---|---|
Checkout link on STORE.lemonsqueezy.com | Keep it as a normal <a href> on a page that runs the script, as in step 2 | No |
Lemon.js overlay opened from a link with the lemonsqueezy-button class | Nothing more. The script adds the ID to the link before the overlay reads it | No |
Custom checkout: a URL your code builds, or an overlay it opens with LemonSqueezy.Url.Open | Add checkout[custom][virling_vid] to the URL first, as in step 3 | Yes, in the browser |
Checkout your server creates with POST /v1/checkouts | Set checkout_data.custom from the cookie, as in step 4 | Yes, on the server |
| Link in an email, a QR code or on another site | Send people to a page that runs the script, and put the checkout link there | No |
Every row also needs the webhook from step 5, which Virling registers when you connect.
Why UTM tags do not reach LemonSqueezy orders
UTM tags live on the URL your visitor landed on. They do not reach the order, for three reasons:
- The visitor is usually a few pages in by the time they click Buy, so the tags are no longer in the address bar.
- Checkout runs on your store's
lemonsqueezy.comaddress, a different site from yours, so nothing on your page travels with the buyer unless you put it in the checkout URL or request. - Custom data you do pass is only returned in webhooks. Reading orders from the LemonSqueezy API will not show it.
LemonSqueezy checkouts accept custom data as checkout[custom][name]=value on a checkout link, or as checkout_data.custom when you create a checkout through the API (LemonSqueezy custom data docs). You could put UTM tags there, but they record only one visit. A visitor ID points back to every visit, including search, referrals and AI answers that carry no tags.
Step 1: add the Virling script
Put the script on every page that links to checkout. It sets a first-party virling_vid cookie and records the source of each visit against it: referrer, UTM tags or direct.
Step 2: no-code checkout links
For links to STORE.lemonsqueezy.com, you write nothing extra. The script adds checkout[custom][virling_vid] to them when the page loads and again on click, and never replaces a value that is already there. A plain link is enough:
<a href="https://STORE.lemonsqueezy.com/checkout/buy/VARIANT_ID">Buy now</a>
Step 3: a browser snippet for custom checkouts
If you build the checkout URL in your own code, add the visitor ID before you send the buyer there:
const url = new URL("https://STORE.lemonsqueezy.com/checkout/buy/VARIANT_ID");
const vid = window.virling?.vid?.();
if (vid) url.searchParams.set("checkout[custom][virling_vid]", vid);
location.href = url.href;Run it after the script has loaded, or the ID will be empty.
Step 4: checkout_data.custom on the server
When your server creates a checkout with POST /v1/checkouts, read the visitor's virling_vid cookie and set it in data.attributes.checkout_data.custom:
"data": {
"type": "checkouts",
"attributes": {
"checkout_data": {
"custom": { "virling_vid": "<the visitor's virling_vid cookie>" }
}
},
"relationships": { ... }
}Step 5: connect LemonSqueezy
Create an API key in LemonSqueezy under Settings, API, and paste it into Virling. Virling registers a webhook on each of your stores for order_created and subscription_payment_success, checks each request's X-Signature, and attaches the visitor ID to the order or invoice. The webhook needs VIRLING_BASE_URL to be a public https:// address; without one, LemonSqueezy payments show as Unattributed.
LemonSqueezy API keys cannot be made read-only and cover every store on your account. Virling stores the key encrypted, and you can delete it in LemonSqueezy at any time. The full setup is in the LemonSqueezy docs and on the LemonSqueezy integration page.
Check that it works in test mode
- Switch your LemonSqueezy store to test mode, create an API key there and connect it. Virling must be on a public
https://address. - Open a private window and visit a page that runs the script through a tagged link, such as
https://yourdomain.com/?utm_source=test&utm_medium=email. - In the same window, click a test mode checkout link on your page and pay with a test card. For a custom checkout, use a test mode variant in your code, and for a server checkout a test mode API key too.
- Wait a minute for the next sync, then open the payments list at
/app/yourdomain.com/payments. The payment shows thetestsource and the Email channel of your tagged visit instead of Unattributed.
Use a new email address for each test, because a later payment by the same customer is a renewal and keeps the first payment's channel. If a step fails, see test your setup.
What test mode does not do: with a test mode key, Virling reads test orders and registers its webhook in test mode, so the test does not cover your live webhook. When you are done, use Replace key in site settings with a live key. A site has one LemonSqueezy connection, and test orders stay in your reports after that.
Why an order stays Unattributed
Open the payment from /app/yourdomain.com/payments and look for Visitor under Details, the visitor ID that came with checkout. If there is none, checkout carried no ID. Then go down this list in order:
- It is a renewal. Renewals keep the channel of the customer's first order. Check that order: if it is Unattributed, or older than the first import, its renewals usually are too.
- Every LemonSqueezy order is Unattributed. The webhook is missing, because Virling was not on a public
https://address when you connected. SetVIRLING_BASE_URL, then use Replace key in site settings to add it. - It is older than the webhook. Custom data only comes by webhook, so orders from before it stay Unattributed.
- The checkout you create has no custom data. On the server, set
checkout_data.custom.virling_vid, as in step 4. In the browser, add it to the URL after the script has loaded, as in step 3. - The link skipped your site. A checkout link opened from an email, a QR code or another site carries no visitor ID.
- The link was not a normal link. The script only tags an
<a href>to alemonsqueezy.comstore address on a page that runs it, not a URL your code opens or a link on another domain. - The visitor had no cookie. In cookieless mode, or before a visitor accepts under Until consent, there is no visitor ID to pass. The same goes for a page where the script is missing or blocked.
- It has a visitor, but no visit in the window. That visitor's sessions all started before the lookback window, or after the payment. Choose a longer window if your buyers take longer, and check that the script runs on every page where visitors arrive.
Every other cause is in Unattributed revenue. An order made before a fix usually stays Unattributed, so place a new one to check it.
What you see after setup
Each order and subscription invoice is joined to the visits of the buyer who paid, so revenue groups by channel, referrer, landing page and campaign. Renewals keep the channel of the subscription's first payment, and refunds are rescanned so a channel does not look better than it is. Orders without a visitor ID, such as checkout links opened straight from an email, show as Unattributed. The steps behind the join are in how to track LemonSqueezy revenue by traffic source, and for choosing which visit gets the credit, see first touch or last touch.
On an Astro site, see Astro LemonSqueezy UTM tracking.
Frequently asked questions
Does LemonSqueezy keep the UTM parameters from my site?
No. Checkout runs on your store's lemonsqueezy.com address, so the tags on your landing page do not travel with the buyer. Pass them, or a visitor ID, as checkout custom data.
How do I pass custom data to a LemonSqueezy checkout?
Add checkout[custom][name]=value to a checkout link, or set checkout_data.custom when you create a checkout with POST /v1/checkouts. With the Virling script on the page, checkout links get checkout[custom][virling_vid] without any code.
Why can I not see the custom data on my orders?
LemonSqueezy only returns checkout custom data in webhooks, not when you read orders from the API. You need a webhook for order_created and subscription_payment_success to receive it.
Should I pass UTM tags or a visitor ID?
A visitor ID. UTM tags in custom data record one visit, usually the last tagged one. A visitor ID points back to every visit, including the ones with no tags, such as search and referrals.
What happens to orders with no visitor ID?
They have no visit to join, so Virling shows them as Unattributed. That includes checkout links opened straight from an email or a QR code, which skip your site.
See which channels bring LemonSqueezy orders
Virling is open source under AGPL. Self-host it free, or use the hosted version with a 14-day free trial. It connects to Stripe, Paddle, Shopify, WooCommerce, Polar, LemonSqueezy, Dodo, Creem and RevenueCat.