Pass the Grosslytics visitor ID in each Merchant of Record’s checkout parameter (reference_id on Polar, metadata_visitor_id on Dodo, and checkout[custom][visitor_id] on Lemon Squeezy) and send signed webhooks to Grosslytics. Each paid order then credits the campaign, post, or AI search answer that brought the buyer.
Lemon Squeezy is winding down. It closed new store sign-ups on November 16, 2026, and plans to stop processing payments on March 31, 2027. The Lemon Squeezy steps below apply to existing stores migrating or tracking remaining renewals; see Lemon Squeezy’s migration guide.
Key takeaways
- Always send marketing traffic to a page running
g.jsbefore checkout; linking straight from social posts to a hosted checkout skips the visit record. - Use each provider’s native metadata key (
reference_idon Polar,metadata.visitor_idon Dodo,custom_data.visitor_idon Lemon Squeezy). - Polar records
billing_reason: "subscription_cycle"as a renewal; Dodo handles full refunds viarefund.succeeded. - Compare gateway fee rates (4% + $0.40 for Dodo vs 5% for Polar) in our payment fee calculator.
What does channel attribution need from a Merchant of Record?
A Merchant of Record handles global tax compliance and invoicing, but it cannot see which blog post or ChatGPT answer drove the click unless your website records the visit and forwards a visitor ID into checkout.
Step 1: How do you record the source before checkout?
Install g.js on your landing and pricing pages and route campaign links through your own domain first:
<script defer src="https://grosslytics.com/g.js"
data-site-id="YOUR_SITE_ID"></script>
Example campaign URL:
https://your-site.example/pricing?utm_source=x&utm_medium=social&utm_campaign=launch-post-1
If a social bio or post links straight to buy.polar.sh or checkout.dodopayments.com, no Grosslytics visit exists to match the eventual webhook. See the tracker installation reference for Content Security Policy settings and self-hosted origins.
Step 2: Which identity field does each provider expect?
On your pages, g.js appends the visitor parameter to supported checkout links when none is set and leaves existing IDs alone. For server-created checkout sessions or JavaScript redirects, read localStorage.getItem('gl_vid') and pass the provider-specific field below:
| Provider | Automatic anchor-link parameter | Server / API checkout field | Webhook field parsed by Grosslytics |
|---|---|---|---|
| Polar | reference_id on buy.polar.sh or polar.sh |
metadata.visitor_id |
data.metadata.visitor_id or data.metadata.reference_id |
| Dodo Payments | metadata_visitor_id on checkout.dodopayments.com |
metadata.visitor_id |
data.metadata.visitor_id |
| Lemon Squeezy | checkout[custom][visitor_id] on *.lemonsqueezy.com |
checkout_data.custom.visitor_id |
meta.custom_data.visitor_id |
Polar checkout links and sessions
Use persistent Polar Checkout Links rather than copying temporary Checkout Session URLs, or pass metadata.visitor_id when calling polar.checkouts.create(). Source: Polar Checkout Links.

// Server: polar is your initialized SDK client; body is a validated request.
const visitorId = typeof body.visitorId === 'string'
&& /^[A-Za-z0-9_-]{1,200}$/.test(body.visitorId)
? body.visitorId : null;
const checkout = await polar.checkouts.create({
products: [process.env.POLAR_PRODUCT_ID],
successUrl: 'https://your-site.example/thanks',
metadata: visitorId ? { visitor_id: visitorId } : {}
});
Dodo Payments checkout sessions
For Dodo Payments links on your page, g.js appends metadata_visitor_id automatically. When creating sessions on your server, pass metadata.visitor_id. Source: Dodo Checkout Sessions.

// Server: client is your initialized DodoPayments SDK client.
const visitorId = typeof body.visitorId === 'string'
&& /^[A-Za-z0-9_-]{1,200}$/.test(body.visitorId)
? body.visitorId : null;
const session = await client.checkoutSessions.create({
product_cart: [{ product_id: process.env.DODO_PRODUCT_ID, quantity: 1 }],
return_url: 'https://your-site.example/thanks',
metadata: visitorId ? { visitor_id: visitorId } : {}
});
Lemon Squeezy checkout links
For existing Lemon Squeezy stores using JavaScript redirects, append checkout[custom][visitor_id] before redirecting, or set checkout_data.custom.visitor_id via API. Source: Lemon Squeezy custom data.
// Browser: run after the Grosslytics tracker has initialized.
let visitorId = null;
try { visitorId = localStorage.getItem('gl_vid'); } catch {}
const checkout = new URL('https://YOUR_STORE.lemonsqueezy.com/checkout/buy/YOUR_VARIANT');
if (visitorId) checkout.searchParams.set('checkout[custom][visitor_id]', visitorId);
window.location.assign(checkout.href);

Check a test payment
Use the provider-specific checkout field and confirm it survives the signed event. Check one tagged test payment per provider before relying on channel totals.
Choose Polar in setup, Dodo’s webhook settings, or Lemon Squeezy in setup. See the closed Stripe sandbox example for a worked example of comparing charges, refunds and fees.
Step 3: Which webhook events should reach Grosslytics?
Point each provider’s signed webhook destination at its dedicated Grosslytics endpoint and save the signing secret in Payments settings:
https://YOUR_ANALYTICS_DOMAIN/api/webhooks/polar?siteId=YOUR_SITE_ID
https://YOUR_ANALYTICS_DOMAIN/api/webhooks/dodo?siteId=YOUR_SITE_ID
https://YOUR_ANALYTICS_DOMAIN/api/webhooks/lemonsqueezy?siteId=YOUR_SITE_ID
| Provider | Payment events ingested | Refund coverage | Signature verification |
|---|---|---|---|
| Polar | order.paid |
Manual reconciliation | Standard Webhooks headers |
| Dodo Payments | payment.succeeded |
refund.succeeded (full refunds) |
Standard Webhooks headers |
| Lemon Squeezy | order_created, subscription_payment_success |
Manual reconciliation | X-Signature HMAC |
Always verify signatures against the raw unmodified request body (Lemon Squeezy signing docs) and configure your site currency in the payment integration reference.
How do renewals, tax deductions, and fees differ?
Grosslytics strips reported sales tax before calculating net revenue and applies each provider’s published fee schedule (5.0% for Polar, 4.0% + $0.40 for Dodo, 5.0% + $0.50 for Lemon Squeezy).
For example, a $120 Dodo payment with $20 tax leaves $100 gross revenue after tax and $95.20 net revenue after Dodo’s estimated $4.80 fee.
- Polar renewals:
billing_reason: "subscription_cycle"marks recurring charges as renewals (Polar order webhooks). - Lemon Squeezy subscriptions: The initial subscription payment can emit both
order_createdandsubscription_payment_success(Lemon Squeezy event sequence). If you turn on both events, check your first subscription charge so you do not double-count the initial invoice. - Dodo renewals: Dodo’s
payment.succeededhandler records renewals as sales alongside one-time payments without a separate renewal flag.
If you are migrating from Lemon Squeezy to Paddle or Stripe, compare setup steps in our Paddle attribution guide and DataFast vs DataBull comparison.
How should you verify your first attributed sale?
Run a test payment from a tagged URL in a fresh browser session and inspect the response status and recorded sale:
| Webhook outcome | What to check |
|---|---|
| Sale appears as Unattributed | Compare browser gl_vid with metadata.visitor_id or reference_id in the webhook payload |
Endpoint returns 401 |
Verify the signing secret in Payments settings matches the provider endpoint |
Endpoint returns 422 |
Match your site reporting currency to the charge currency |
Endpoint returns 200 with ignored or deduplicated |
Grosslytics already recorded that payment ID, or the event type is not handled |
Compare first-touch, last-touch, and linear attribution in the dashboard definitions, and see a sandbox trace in our ChatGPT revenue walkthrough.
Frequently asked questions
Can I use checkout[custom][visitor_id] for Polar and Dodo too?
No. checkout[custom][visitor_id] is specific to Lemon Squeezy. Polar links use reference_id, Dodo links use metadata_visitor_id, and server checkout sessions pass metadata.visitor_id.
Does Grosslytics handle Polar or Dodo refunds?
On Dodo Payments, refund.succeeded removes full refunds from revenue and marks the sale refunded; partial Dodo refunds stay in revenue. Reconcile Polar and Lemon Squeezy refunds manually.
Does Grosslytics classify Dodo subscription renewals separately?
Not yet. Dodo’s payment.succeeded handler credits recurring payments to the original visitor’s channel, though they currently count under new sales rather than a separate renewal bucket.
How does Grosslytics compare to DataBull for Dodo Payments?
Both support Stripe, Polar, and Dodo Payments on your own Cloudflare account; Grosslytics is open-source (AGPL-3.0), deducts gateway fees automatically, and adds Paddle, Razorpay, PayPal, Cashfree, Gumroad, and RevenueCat. See the full breakdown in DataBull alternatives.