Revenue attribution
Lemon Squeezy
Attribute Lemon Squeezy orders from the Checkout API or plain checkout links.
Snippets use YOUR_SITE_ID as a placeholder. Sign in and they're filled in with your real site id.
1. Connect Lemon Squeezy
- In VisitTrack, open Settings → Revenue and pick Lemon Squeezy.
- Copy the webhook URL shown there. It looks like
https://visitrack.app/api/lemonsqueezy-webhook/YOUR_SITE_ID. - In Lemon Squeezy: Settings → Webhooks → +, with a signing secret of your choice. Paste the URL and subscribe to
order_createdandorder_refunded. - Copy the same signing secret Lemon Squeezy gives you back into VisitTrack and press Connect. It's stored encrypted and only used to verify signatures.
2. Pass the visitor id
Lemon Squeezy calls it custom data. Set visitrack_visitor_id there, either through the API or as a URL parameter on a checkout link.
import { createCheckout } from "@lemonsqueezy/lemonsqueezy.js";
const { data } = await createCheckout(storeId, variantId, {
checkoutData: {
custom: { visitrack_visitor_id: visitorId ?? "" },
},
});
return Response.json({ url: data?.data.attributes.url });Events
| Event | What VisitTrack does |
|---|---|
order_created | Records the order (total, currency, user_email) against the visitor in meta.custom_data.visitrack_visitor_id. |
order_refunded | Subtracts refunded_amount from the original order. |
| anything else | Acknowledged with 200 and ignored. |
Subscriptions
Recurring payments don't create a new order in Lemon Squeezy, so only the first payment of a subscription is attributed. That's usually the one you care about: it's the payment the channel actually earned.
Test it
- Open your site in a normal browser tab so the tracker records a visit (localhost is ignored unless the script tag has
data-allow-local). - Complete a checkout in test mode.
- Open Revenue in the dashboard. The payment shows up within a few seconds, with the referrer, campaign and landing page that brought that visitor in.
Nothing showed up?
See Missing or unattributed payments. The webhook response body always says why a payment was skipped.
Something missing? Tell us.
AI agent or LLM? Read this page as markdown.