Lemon Squeezy revenue attribution
Tie paid Lemon Squeezy customers back to the campaign that brought them in.
Two steps: connect your Lemon Squeezy account with an API key, and pass the visitor id as checkout custom data. No webhook setup is required — Piqo configures payment notifications on your store automatically, including subscription renewals.
1. Connect your Lemon Squeezy account
- In Lemon Squeezy, go to Settings → API and create an API key.
- In Piqo, open your site's Settings → Revenue attribution, pick Lemon Squeezy, and paste the key. That's the whole setup — Piqo registers the payment notifications on your store for you (initial purchases and every subscription renewal).
2. Pass the visitor id into checkout
Attach piqo_visitor_id to the checkout's custom data. Lemon Squeezy sends it back to Piqo with the payment. With the official @lemonsqueezy/lemonsqueezy.js SDK:
// app/api/create-checkout/route.js
import { cookies } from 'next/headers';
import { createCheckout } from '@lemonsqueezy/lemonsqueezy.js';
export async function POST() {
const cookieStore = await cookies();
const { data, error } = await createCheckout(storeId, variantId, {
// ... your existing productOptions, checkoutOptions, etc.
checkoutData: {
custom: {
piqo_visitor_id: cookieStore.get('piqo_visitor')?.value,
piqo_session_id: cookieStore.get('piqo_session')?.value, // optional
},
},
});
}No backend? Append the visitor id to your hosted buy link instead:
const url = 'https://yourstore.lemonsqueezy.com/buy/xxxx'
+ '?checkout[custom][piqo_visitor_id]=' + getCookie('piqo_visitor')
+ '&checkout[custom][piqo_session_id]=' + getCookie('piqo_session'); // optionalSelling through Payment Links? (no code)
- In your Lemon Squeezy dashboard, select the product — it opens an overlay with the product details.
- For Confirmation Modal and Email Receipt, update the Button Link to redirect customers to your website.
- Add
?order_id=[order_id]to that URL — Lemon Squeezy replaces[order_id]with the real order id:
https://yourdomain.com/thank-you?order_id=[order_id]Piqo automatically looks for the order_id in the URL and attributes the payment to that visitor. Duplicate payment events are ignored, so multiple redirects are harmless. This works best when customers complete the purchase on the same device and browser.
What you'll see
As soon as a customer pays, the conversion shows up on your dashboard's Conversions page with the channel / country / UTM columns from the matching pageview, and its revenue lands on the chart. Subscription renewals are tracked automatically and credited to the channel that originally acquired the customer. Payments without the custom data still count toward revenue totals — they just show as Direct.