virling Pricing Self-host Demo Changelog Agencies GitHub Start free trial
integrations / lemonsqueezy for ai apps

See which channel brings your AI app's paying users on LemonSqueezy.

For founders of AI apps who sell subscriptions or credits through LemonSqueezy. Virling ties each paying user to the channel that brought them, whether that was ChatGPT, Reddit, X or a newsletter, so you see which one brings the users who pay, not only the ones who sign up and spend free credits. Open source under AGPL, hosted or self-hosted.

Start free trial See the demo

A LemonSqueezy order tells you who bought and what they paid, not which visit sent them. Virling gives each visitor an ID in a first-party cookie, carries it into checkout as custom data, and credits the order to the visits before it. Model and lookback window explains which visit gets the credit.

Checkout links with custom data

LemonSqueezy checkout takes custom data as checkout[custom][KEY] query parameters on a checkout link, or as checkout_data.custom when you create a checkout through the API. Virling uses the key virling_vid.

  • Buy links on your pages. On any page that runs the script, a link to STORE.lemonsqueezy.com gets checkout[custom][virling_vid] added when the page loads and again on click, unless the link already has it. Put the plan and credit pack buttons on your pricing page or inside your app, where the script runs.
  • Checkouts you create on your server. With POST /v1/checkouts, set data.attributes.checkout_data.custom to { "virling_vid": "<the visitor's virling_vid cookie>" }. This suits an app that creates a checkout per signed-in user.
  • Checkout URLs built in the browser. Read the ID from the script and add it yourself:
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;

window.virling?.vid?.() is empty while the script is blocked or still loading, which is why the code checks it. A buy link in an email or a message has no custom data, so that order counts as Unattributed revenue unless the buyer has paid before.

The webhook Virling needs, and why

The LemonSqueezy API lists orders and subscription invoices without the checkout's custom data. Only webhooks carry it, in meta.custom_data. So Virling reads two ways: the API every minute for amounts, refunds and subscription status, and a webhook for the visitor ID.

  • Registered for you. When you connect, Virling adds a webhook to each store on the key for order_created and subscription_payment_success, pointing at /api/webhooks/lemonsqueezy/ on your Virling address. Connecting again with a new key updates the same webhook, and a test mode key creates it in test mode.
  • Signed. Each webhook has its own signing secret, stored encrypted. Virling checks the HMAC-SHA256 in X-Signature before it attaches the visitor ID to the order or invoice.
  • Only from the day you connect. Orders imported from the 90-day backfill never had a webhook, so they count as revenue but stay Unattributed.
  • Self-hosted needs a public address. LemonSqueezy has to reach the webhook, so VIRLING_BASE_URL must be a public https:// address. Without one, no webhook is registered.

Subscriptions and one-off credit packs

AI apps on LemonSqueezy usually sell a monthly plan, a one-time credit pack variant, or both. Virling handles each the way LemonSqueezy records it.

  • A new subscription. The first charge is an order, sent with order_created and its custom data. LemonSqueezy also makes a subscription invoice with billing reason initial for that charge; Virling skips it, so the charge counts once.
  • Renewals and plan changes. Later invoices arrive with subscription_payment_success. Billing reason renewal or updated marks them as renewals, and they copy the channel of the customer's first payment, matched by LemonSqueezy customer ID.
  • Credit packs. A one-time variant is a plain order. When the pack is a customer's first purchase, its custom data credits the visits before it. When the customer has paid before, the pack keeps the channel of that first payment, so a user who subscribed after a Reddit thread and then buys packs adds all of it to Reddit.
  • Who still pays. Subscription status is read once an hour. on_trial, active and past_due count as live, and cancelled stays live until its ends_at, which the Retention page uses to show which channel brings users who stay.
  • Refunds. LemonSqueezy does not change an order's creation time when it is refunded, so Virling reads the last 60 days again every 6 hours and lowers the order or invoice by what was refunded.

Set it up

  1. Add the site and the script. Click + Add a site, then paste the tag before </head> on your landing page and your app. yourapp.com and app.yourapp.com share one visitor ID. Leave cookieless mode off.
  2. Connect LemonSqueezy. Create a key under Settings, API and paste it under payments. LemonSqueezy keys cannot be made read-only and cover every store on the account; Virling reads orders, subscriptions and subscription invoices, adds its webhook, and stores the key encrypted.
  3. Pass the visitor ID. Use buy links on your pages, or add virling_vid to the custom data of checkouts you create, as shown above.
  4. Test it. In test mode, visit your site through a tagged link, buy with a test card, and the payment shows the test source and your link's channel within a minute.

LemonSqueezy UTM tracking covers each kind of checkout, and ChatGPT revenue tracking shows how to read which ChatGPT visits pay. Every setting is on the LemonSqueezy integration page, and Virling for AI apps covers other payment providers.

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

Which channel brings paying users to my AI app on LemonSqueezy?

Connect a LemonSqueezy API key, keep your buy links on pages that run the script, and add virling_vid to the custom data of any checkout you create. The webhook brings that ID back with each order, and the Channels card shows whether ChatGPT, Reddit, X or a newsletter brought the users who pay.

Which channel gets credit for a LemonSqueezy renewal?

The channel of the customer's first payment. Subscription invoices with billing reason renewal or updated copy its channel, referrer, campaign and landing page, matched by LemonSqueezy customer ID.

Which channel gets credit for a credit pack bought later?

The channel of the customer's first payment, like a renewal, because any later payment by the same LemonSqueezy customer keeps it. Only a pack that is the customer's first purchase is credited from its own checkout's custom data.

Are visits from ChatGPT and Perplexity tracked?

Yes. Visits referred by chatgpt.com, chat.openai.com, perplexity.ai, claude.ai, gemini.google.com, copilot.microsoft.com and chat.deepseek.com get the AI channel, so revenue from AI answers shows on its own rows. An assistant that sends no referrer leaves the visit as Direct.

Why does Virling need a webhook for LemonSqueezy?

The LemonSqueezy API does not return checkout custom data, and the visitor ID travels in custom data. Virling registers a webhook for order_created and subscription_payment_success on each store when you connect, and checks each one against its X-Signature before attaching the visitor ID.

Is a new subscription's first charge counted twice?

No. LemonSqueezy records it as an order and as a subscription invoice with billing reason initial. Virling imports the order, which carries the custom data, and skips that invoice.

Full guides: LemonSqueezy in the docs, Link checkout to visits and Renewals.

Start free trial