Skip to main content
Connect LemonSqueezy to automatically track revenue and link it to your marketing campaigns.

Supported LemonSqueezy methods

  • LemonSqueezy Checkout - Hosted checkout pages
  • Payment Links - Shareable payment links
  • Other LemonSqueezy methods - Any LemonSqueezy payment method

Setup

Step 1: Get your webhook URL

Your webhook URL is:
https://your-domain.com/api/webhooks/lemonsqueezy

Step 2: Configure LemonSqueezy webhook

  1. Go to your LemonSqueezy Dashboard
  2. Click “Create webhook”
  3. Enter your webhook URL: https://your-domain.com/api/webhooks/lemonsqueezy
  4. Select events to listen for:
    • order_created
    • order_updated
    • subscription_created
    • subscription_updated
  5. Copy the Signing secret (you’ll need this for verification)

Step 3: Add webhook secret to environment

Add your LemonSqueezy webhook secret to your environment variables:
LEMONSQUEEZY_WEBHOOK_SECRET=your-secret-key

LemonSqueezy Checkout

Include website ID in product options

When creating a checkout, include the website ID in product options:
const checkout = await lemonSqueezy.checkouts.create({
  store_id: "your-store-id",
  variant_id: "your-variant-id",
  product_options: {
    websiteId: "your-website-id",
    // You can also include visitor/session IDs if available
    visitorId: visitorId,
    sessionId: sessionId,
  },
});

Redirect to checkout

window.location.href = checkout.data.attributes.url;
For Payment Links, include the website ID in the product options when creating the link:
  1. Go to your LemonSqueezy Dashboard
  2. Create a Payment Link
  3. In the product options, add: websiteId: 'your-website-id'
Or use customer email matching:
  1. Enable user identification in PostMetric
  2. Identify users before they purchase
  3. Payments will be linked via email matching

View revenue data

Once payments are linked, you can view:
  • Revenue by source/channel
  • Revenue by campaign
  • Conversion rates
  • Average order value

Subscriptions

Subscription events are tracked separately. When a subscription is created or updated, it’s recorded in PostMetric. You can track recurring revenue separately from one-time payments.

Troubleshooting

Payments not appearing

  1. Check that the webhook is configured correctly
  2. Verify the websiteId is included in product options or metadata
  3. Check webhook logs in LemonSqueezy Dashboard
  4. Verify the webhook secret is set correctly

Payments not linked to visitors

  1. Ensure visitor/session IDs are included in product options
  2. Enable user identification for email matching fallback
  3. Check that the visitor was tracked before the payment

Next steps

Revenue attribution guide

Learn more about revenue attribution