Refgrow
Back to blog

How to Track Affiliate Conversions with LemonSqueezy

Alex Belogubov
How to Track Affiliate Conversions with LemonSqueezy

Running an affiliate program for your SaaS product means nothing if you can't accurately track conversions. Every missed conversion is a frustrated affiliate, a lost relationship, and revenue left on the table. If you're using LemonSqueezy as your payment processor, you need a reliable system that captures every sale, attributes it to the right affiliate, and calculates commissions automatically.

In this guide, we'll walk through exactly how to set up affiliate conversion tracking with LemonSqueezy using Refgrow — from connecting your API credentials to verifying your first tracked conversion. By the end, you'll have a fully automated pipeline that handles attribution, commission calculation, and affiliate payouts without manual intervention.

Why Accurate Conversion Tracking Matters

Before diving into the technical setup, let's establish why conversion tracking is the backbone of any affiliate program.

  • Affiliate trust: Affiliates promote your product because they expect to be paid. If conversions go missing or take days to appear, your best promoters will move to competitors who have their tracking dialed in.
  • Revenue attribution: Without precise tracking, you're flying blind. You won't know which affiliates drive real revenue, which campaigns convert, or where to allocate your marketing budget.
  • Compliance and auditing: Payment disputes happen. Having a clear, timestamped record of every conversion — tied to a specific webhook event — protects both you and your affiliates.
  • Scaling decisions: When you can see exactly which affiliates generate the highest LTV customers, you can create tiered commission structures that reward your top performers.

How LemonSqueezy Webhooks Work

LemonSqueezy uses a webhook-based event system to notify external services about purchases, subscription changes, and refunds. When a customer completes a purchase on your LemonSqueezy checkout, the platform fires a series of HTTP POST requests to any URLs you've configured.

Key Webhook Events for Affiliate Tracking

LemonSqueezy dispatches dozens of event types, but for affiliate conversion tracking, these are the ones that matter:

  1. order_created: Fired when a one-time purchase is completed. Contains the full order details including amount, customer email, and any custom data you passed to the checkout.
  2. subscription_created: Fired when a new subscription begins. This is your primary conversion event for recurring SaaS products.
  3. subscription_updated: Fired on plan changes — upgrades, downgrades, and quantity adjustments. Important for tracking upsell conversions.
  4. subscription_payment_success: Fired on each successful recurring payment. Essential if you're paying affiliates recurring commissions.
  5. order_refunded: Fired when a refund is issued. Refgrow uses this to automatically reverse or adjust the corresponding affiliate commission.

The Attribution Chain

Here's how the full attribution chain works when a referred customer purchases through LemonSqueezy:

  1. A potential customer clicks an affiliate's referral link (e.g., yourapp.com/?ref=john).
  2. Refgrow's tracking script sets a first-party cookie with the referral code.
  3. When the customer reaches your LemonSqueezy checkout, Refgrow passes the referral code as custom data in the checkout URL.
  4. LemonSqueezy processes the payment and fires the order_created or subscription_created webhook.
  5. Refgrow receives the webhook, extracts the referral code from the custom data, matches it to the affiliate, and records the conversion.

Step-by-Step: Setting Up LemonSqueezy Conversion Tracking

Prerequisites

Before you begin, make sure you have:

  • An active Refgrow account (the 14-day free trial works for this setup).
  • A LemonSqueezy store with at least one product configured.
  • Refgrow's tracking script installed on your website.

Step 1: Connect Your LemonSqueezy API Key

First, generate an API key in your LemonSqueezy dashboard:

  1. Log into LemonSqueezy and navigate to Settings → API.
  2. Click Create API Key. Give it a descriptive name like "Refgrow Integration."
  3. Copy the generated API key — you'll only see it once.

Now add it to Refgrow:

  1. In your Refgrow dashboard, go to Project Settings → Integrations.
  2. Select LemonSqueezy from the payment provider list.
  3. Paste your API key into the LemonSqueezy API Key field.
  4. Enter your LemonSqueezy Store ID (found in your LemonSqueezy store settings).
  5. Click Save & Verify. Refgrow will make a test API call to confirm the credentials are valid.

Step 2: Configure the Webhook URL

With the API key connected, you need to tell LemonSqueezy where to send webhook events.

  1. In your Refgrow project settings, copy the LemonSqueezy Webhook URL. It will look like: https://app.refgrow.com/webhook/lemonsqueezy/YOUR_PROJECT_ID
  2. Also copy the Webhook Signing Secret that Refgrow generates for you.
  3. Go to your LemonSqueezy dashboard → Settings → Webhooks.
  4. Click Add Webhook.
  5. Paste the Refgrow webhook URL in the Callback URL field.
  6. Paste the signing secret in the Secret field.
  7. Select the following events to subscribe to:
    • order_created
    • subscription_created
    • subscription_updated
    • subscription_payment_success
    • order_refunded
    • subscription_cancelled
  8. Click Save.

Important: Refgrow verifies every incoming webhook using HMAC-SHA256 signature validation. This prevents spoofed webhook attacks — only genuine LemonSqueezy events will be processed.

Step 3: Configure the Checkout Overlay

For Refgrow to attribute a purchase to the correct affiliate, the referral code needs to travel from your website to the LemonSqueezy checkout. Refgrow's tracking script handles this automatically.

If you're using LemonSqueezy's overlay checkout (recommended), make sure your checkout links include the data-refgrow attribute:

<a href="https://yourstore.lemonsqueezy.com/checkout/buy/..."
   class="lemonsqueezy-button"
   data-refgrow="true">
  Buy Now
</a>

Refgrow's tracking script will automatically append the referral code as custom data to the checkout URL when a referred visitor clicks the button. No additional JavaScript is needed.

For hosted checkout pages, Refgrow intercepts the redirect and appends the referral metadata as a URL parameter that LemonSqueezy passes through to the webhook payload.

Step 4: Test with a Purchase

Before going live, you should verify the full tracking pipeline with a test purchase.

  1. In Refgrow, create a test affiliate or use your own affiliate account.
  2. Copy the affiliate's referral link.
  3. Open the referral link in an incognito/private browser window.
  4. Navigate to your product page and initiate a checkout.
  5. LemonSqueezy supports test mode — make sure your store is in test mode so you can use test card numbers (e.g., 4242 4242 4242 4242).
  6. Complete the purchase.

Within seconds, you should see the conversion appear in your Refgrow dashboard under Conversions. The conversion record will show:

  • The affiliate it was attributed to.
  • The purchase amount and calculated commission.
  • The LemonSqueezy order ID for cross-referencing.
  • The webhook event type that triggered it.
  • A timestamp of when the conversion was recorded.

Step 5: Verify Conversions and Commission Calculation

After your test purchase, verify these details in the Refgrow dashboard:

  • Attribution: Check that the conversion is attributed to the correct affiliate. Click into the conversion detail to see the full attribution chain — which referral code was used, the cookie timestamp, and the webhook event.
  • Commission amount: Verify the commission matches your configured rate. If you've set a 25% recurring commission and the purchase was $49, the affiliate commission should be $12.25.
  • Recurring tracking: If this was a subscription, wait for (or simulate) a renewal payment. The subscription_payment_success event should create a new commission entry for the renewal.

Advanced Configuration

Product-Specific Commission Rates

Not all products deserve the same commission rate. A high-margin digital course might warrant a 40% commission, while a low-margin API tool might only support 15%. Refgrow lets you set commission rates per LemonSqueezy product.

In your Refgrow project settings, navigate to Products & Commissions. You can map specific LemonSqueezy product IDs to custom commission rates. When a webhook arrives, Refgrow checks for a product-specific override before falling back to the default project commission rate.

Handling Refunds Automatically

When a customer requests a refund through LemonSqueezy, the order_refunded webhook fires. Refgrow automatically:

  1. Matches the refunded order to the original conversion.
  2. Marks the conversion as refunded.
  3. Adjusts the affiliate's pending balance — if the commission hasn't been paid out yet, it's removed. If it has already been paid, Refgrow flags it for recovery in the next payout cycle.

This eliminates the manual work of chasing refund clawbacks and keeps your affiliate accounting clean.

Multi-Tier Commissions

If your affiliate program uses a tiered structure (e.g., affiliates earn 25% for the first 10 conversions, then 30% after), Refgrow handles this automatically. Commission tiers are evaluated at the time each webhook is processed, so affiliates see their rate increase in real-time as they hit milestones.

Troubleshooting Common Issues

Conversions Not Appearing

If a purchase was made but no conversion shows up in Refgrow, work through this checklist:

  1. Check the webhook logs: In your Refgrow dashboard, go to Webhooks → Logs. If LemonSqueezy sent the webhook but Refgrow rejected it, you'll see an error with details.
  2. Verify the signing secret: The most common issue is a mismatched webhook signing secret. Re-copy the secret from Refgrow and update it in LemonSqueezy.
  3. Check event subscriptions: Make sure you've subscribed to the correct events in LemonSqueezy. If you only subscribed to order_created but you're selling subscriptions, you need subscription_created as well.
  4. Inspect the referral cookie: Open your browser's developer tools, go to Application → Cookies, and look for the Refgrow referral cookie. If it's missing, the tracking script may not be installed correctly.
  5. Retry failed webhooks: LemonSqueezy retries failed webhooks automatically, but you can also manually retry from the LemonSqueezy webhook logs.

Wrong Affiliate Attributed

Attribution conflicts can occur when a customer clicks multiple affiliate links. Refgrow uses a last-click attribution model by default — the most recent referral code wins. If you need first-click attribution, you can configure this in your project settings under Attribution Model.

Duplicate Conversions

LemonSqueezy may occasionally send duplicate webhook events (especially during retries). Refgrow handles this with idempotency checks — each webhook event ID is stored, and duplicate events are silently ignored. You don't need to do anything special to handle this.

Webhook Delivery Failures

If LemonSqueezy can't reach your Refgrow webhook URL (e.g., due to a temporary network issue), it will retry the webhook multiple times over the next 24 hours. Refgrow processes these delayed webhooks correctly — the conversion timestamp reflects the original purchase time, not the webhook delivery time.

Manual Tracking vs. Automated Webhook Tracking

Some teams try to track affiliate conversions manually — using spreadsheets, UTM parameters in analytics tools, or periodic CSV exports from LemonSqueezy. Here's why that approach breaks down quickly:

Factor Manual Tracking Automated (Refgrow + Webhooks)
Speed Hours to days (batch processing) Real-time (seconds after purchase)
Accuracy Prone to human error, missed entries Cryptographically verified webhooks
Refund handling Manual cross-referencing Automatic commission adjustment
Recurring revenue Complex spreadsheet formulas Each renewal tracked automatically
Affiliate visibility Periodic email reports Real-time dashboard for affiliates
Scale Breaks at ~20 affiliates Handles thousands of affiliates
Audit trail Fragmented across tools Complete webhook log with payloads

The manual approach might work for your first few affiliates, but it becomes unsustainable quickly. Automated webhook tracking isn't just more convenient — it's more accurate, faster, and builds the trust that keeps affiliates promoting your product.

What Happens After a Conversion Is Tracked

Once Refgrow records a conversion from a LemonSqueezy webhook, the downstream automation kicks in:

  1. Commission calculation: The commission is calculated based on your configured rates (project default, product-specific, or affiliate-specific override).
  2. Affiliate notification: The affiliate sees the new conversion in their real-time dashboard. If you've enabled email notifications, they also receive an email.
  3. Payout accumulation: The commission is added to the affiliate's pending balance. When the balance reaches your minimum payout threshold, it becomes eligible for payout.
  4. Payout processing: Depending on your payout schedule, Refgrow processes payouts via PayPal, Wise, or manual transfer. The affiliate receives their earnings with a clear breakdown of which conversions the payout covers.

Get Started in 10 Minutes

Setting up LemonSqueezy affiliate conversion tracking with Refgrow takes less than 10 minutes. You don't need to write custom webhook handlers, build attribution logic, or manage commission spreadsheets. The entire pipeline — from referral click to affiliate payout — is automated.

If you're running a SaaS product on LemonSqueezy and want to launch an affiliate program that your partners will actually trust, Refgrow handles the hard part so you can focus on growing your product.

Start your free 14-day trial and have your LemonSqueezy affiliate tracking live today. No credit card required.

More from the blog

Ready to launch your affiliate program?

14-day free trial · No credit card required

Start Free Trial
Track Affiliate Conversions with LemonSqueezy (2026)