Lemon Squeezy affiliate tracking, renewals included.

Lemon Squeezy affiliate tracking with AffiliateTracking takes one line on your checkout links and one webhook. First orders, subscription renewals and refunds all land in the same ledger.

Orders and renewalsPartial refundsCloud and self-host

Your checkout link, for a visitor from JaneExample
Your linkhttps://yourstore.lemonsqueezy.com/checkout/buy/8f2c…
With the token added…/checkout/buy/8f2c…?checkout[custom][token]=…
When they payorder_created → Jane's commission, checked by 12 fraud rules

From click to commission

How a Lemon Squeezy sale finds its affiliate

The same path as every other sale, with Lemon Squeezy's custom data carrying the token.

  1. 01The click

    A visitor opens an affiliate's link. We record the click, and they land on your site with a signed token.

  2. 02The script keeps it

    t.js saves the token in a cookie on your domain for your attribution window, 30 days unless you change it.

  3. 03The link carries it

    Your checkout links get the token as custom data. Lemon Squeezy keeps it on the order.

  4. 04Lemon Squeezy tells us

    order_created arrives, the 12 fraud rules run, and the customer stays linked to that affiliate.

Set it up in four steps

Step 2 is the only code. The rest happens in Lemon Squeezy and in your settings.

  1. Add the script to your site

    Paste it on every page, right before </head>. Your workspace settings show the tag with your own address filled in.

  2. Add the token to your checkout links

    This adds it to every Lemon Squeezy link on the page, overlay buttons included. Creating checkouts through the API? Pass it as checkout_data.custom.token instead.

  3. Add a webhook in Lemon Squeezy

    In Settings, then Webhooks, add your address, make up a signing secret and tick four events.

  4. Paste the same signing secret

    On cloud, paste it into the Lemon Squeezy field under Billing webhooks in your settings. AffiliateTracking checks every event against it before it writes anything.

What each Lemon Squeezy event does

Each event has to pass Lemon Squeezy's signature check, and it counts once, however many times Lemon Squeezy sends it.

Orders placed in test mode never earn commission.
Lemon Squeezy eventWhat AffiliateTracking does
order_createdReads the token, credits the affiliate and links the customer to them for good.
subscription_payment_successEach renewal credits the linked affiliate. No token needed.
order_refundedTakes back the same share of the commission. Partial refunds take back part of it.
subscription_payment_refundedDoes the same for a refunded renewal payment.

Good to know before you start

Four details worth knowing before you go live.

Free trials

Checkout links the customer to the affiliate. Their first paid renewal earns the commission.

Renewals need no token

Once a customer has an affiliate, every renewal credits that same affiliate, with no custom data needed.

Test mode stays out

Test orders pass through without touching the ledger, so you can try checkout without paying anyone.

Keep the name "token"

The custom data key has to be token, exactly. Other custom data you pass stays untouched.

Lemon Squeezy FAQ

How do I run an affiliate program on Lemon Squeezy?

Lemon Squeezy takes the payments and AffiliateTracking tracks who sent each one. Add the script to your site, add the token to your checkout links, and point a webhook at your workspace. Then invite affiliates.

Lemon Squeezy has its own affiliates. Why use this?

Use whichever fits. AffiliateTracking holds suspicious sales before you pay them and keeps every cent in a ledger you can check. It also works the same way if you ever move to Stripe or Paddle.

Do I need a developer?

For step 2, a little. It's one short script on your pages. Everything else happens in settings.

Does it work with the checkout overlay?

Yes. The overlay opens the same checkout link, so the token rides along.

What happens when I refund an order?

The same share of the commission comes back. If you already paid the affiliate, it comes off their next payout.

Your Lemon Squeezy store,
now with affiliates.

Try cloud free for 14 days. Or buy self-host for $99 once.