Install on Lemon Squeezy
Two attribution paths for Lemon Squeezy checkouts. The redirect-URL trick fires a convert event on a brand-owned thank-you page; the order_created webhook relay handles attribution server-side.
Lemon Squeezy is a Merchant of Record. Like Paddle, the checkout is Lemon-Squeezy-hosted and does not expose a custom-JS slot for security and PCI reasons. Because there is no merchant Stripe account, the Stripe Connect webhook rail Rekomi uses for Stripe-native customers does not apply here. Lemon Squeezy needs one of two install patterns: the redirect-URL trick to a brand-owned thank-you page, or a server-side relay from Lemon Squeezy's order_created webhook. Both work; the second is more reliable.
Install the head script
Paste the Rekomi head script in your marketing site's <head> so the affiliate cookie is set on every landing page traffic lands on.
<script>
(function(){
var s=document.createElement('script');
s.src='https://js.rekomi.com/v1/rekomi.js';
s.async=true;
s.dataset.programId='YOUR_PROGRAM_ID';
document.head.appendChild(s);
})();
</script>The program ID is in Settings > Tracking in the Rekomi dashboard. The cookie set here is what the conversion-firing step below reads from.
Path A: redirect URL to a brand-owned thank-you page
This path is simpler to set up and works for most subscription + one-time-purchase products. The browser pixel does the conversion firing on a page you control.
Step 1. Build a thank-you page on your domain (e.g., https://yourdomain.com/thanks) and paste the head script in its <head> as above.
Step 2. In Lemon Squeezy, open Products > [your product] > Checkout > Redirect URL after purchase. Paste your thank-you URL with order parameters templated in:
https://yourdomain.com/thanks?order_id={order_number}&amount={order_total}&email={user_email}Lemon Squeezy substitutes the placeholders with real values at redirect time.
Step 3. On the thank-you page, parse the URL params and fire the convert event:
<script>
document.addEventListener('DOMContentLoaded', function(){
var params = new URLSearchParams(window.location.search);
if (!params.get('order_id')) return;
window.Rekomi.convert({
external_event_id: params.get('order_id'),
amount_cents: Math.round(parseFloat(params.get('amount')) * 100),
currency: 'USD', // or read from URL if you template it in
customer_email: params.get('email'),
});
});
</script>The amount parameter Lemon Squeezy substitutes is a decimal (e.g., 49.00). Multiply by 100 to convert to cents before passing to Rekomi.
Path B: order_created webhook relay (more reliable)
The webhook path bypasses the browser entirely and is the right choice if you sell across multiple checkouts (LemonJS overlays, hosted Buy buttons, subscription renewals).
Step 1. In Lemon Squeezy, go to Settings > Webhooks > Create webhook. Subscribe to order_created (and subscription_payment_success if you sell subscriptions).
Step 2. Point the webhook at a handler on your backend.
Step 3. Inside the handler, validate Lemon Squeezy's signature (they sign every webhook with the secret you set during webhook creation), then POST to Rekomi's S2S endpoint with HMAC.
// Node example
app.post('/webhooks/lemonsqueezy', async (req, res) => {
// 1. Verify Lemon Squeezy signature (X-Signature header).
// 2. Find the referral. LS does not pass referral metadata by default;
// set it via the custom_data param on Buy buttons or LemonJS:
// <a href="https://store.lemonsqueezy.com/buy/xxx?checkout[custom][rekomi_affiliate_slug]=SLUG">
// The browser hydrates SLUG from window.Rekomi.getReferral() before render.
const event = req.body;
const referral = event.data.attributes.first_subscription_item?.custom_data?.rekomi_affiliate_slug
|| event.meta.custom_data?.rekomi_affiliate_slug;
if (!referral) return res.sendStatus(200);
const body = JSON.stringify({
external_event_id: event.data.id,
affiliate_slug: referral,
amount_cents: event.data.attributes.total, // already cents in LS webhooks!
currency: event.data.attributes.currency,
customer_email: event.data.attributes.user_email,
});
const signature = hmacSha256(body, process.env.REKOMI_S2S_SECRET);
await fetch('https://api.rekomi.com/api/tracking/s2s', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Rekomi-Signature': signature,
},
body,
});
res.sendStatus(200);
});The custom_data passing on Buy button URLs is how you carry the referral from the visitor's browser into Lemon Squeezy's order record. On every "Buy" link or LemonJS button, render the URL server-side or stamp it client-side with the referral from window.Rekomi.getReferral().
Refunds
Subscribe to subscription_payment_refunded (subscriptions) or order_refunded (one-time). POST the refund to Rekomi's /api/tracking/refund with the same external_event_id from the original order. Rekomi reverses the commission.
Quirks worth knowing
Lemon Squeezy returns amounts as integers, NOT decimals. Their webhook payloads already report total in cents, so you do NOT need to multiply by 100 in the webhook relay (unlike the redirect-URL path where the URL substitution gives you a decimal). This is the opposite of the Paddle pattern; be careful which path you are on.
The redirect-URL trick exposes order data in URL params. If your thank-you page is publicly indexable, search engines could in theory capture URL fragments from referrer headers or sitemap submissions. Set <meta name="robots" content="noindex, nofollow"> on the thank-you page to prevent indexing.
Custom data is per-checkout, not per-buyer. If you have a single Buy button URL that you share publicly without stamping the referral, every order on that link arrives without a referral. The redirect-URL path is forgiving here (it captures whoever visited your thank-you page with the right URL params); the webhook path is not (the affiliate slug must be in the order's custom_data, and if it is missing, the referral is lost).
Troubleshooting
Conversion does not appear after a Lemon Squeezy order. Confirm the redirect URL has the correct order param template ({order_number}, {order_total}, {user_email} — Lemon Squeezy is strict about the names). If using the webhook path, check that custom_data is being attached to the checkout URL, and verify the webhook signature validates.
Amount is off by 100x. You are mixing the redirect-URL path (decimal) with the webhook path (cents) and applying the wrong multiplier. Webhooks: don't multiply. Redirect URL: multiply by 100.
Affiliate cookie is missing on the thank-you page. Lemon Squeezy hosts the checkout on store.lemonsqueezy.com. The redirect from there to your thank-you page is a top-level navigation, so cross-domain cookies are not the issue, but the affiliate cookie was set on your domain before the buyer left. As long as the head script ran on at least one page before the buyer clicked Buy, the cookie is present on return.
Related
Install on Shopify
Install the Rekomi app from the Shopify App Store for a native, no-code setup that tracks orders for affiliate attribution. Or use the Custom Pixel plus webhook-to-S2S relay fallback if you prefer to wire it up yourself.
Install on Gumroad
Capture Gumroad sales via the Ping URL webhook relayed to Rekomi's S2S endpoint. Gumroad is the only no-code platform that ships server-side by default.