peregrine
DocsDemoGet started

Integration

Lemon Squeezy analytics: see which channel your buyers came from

Lemon Squeezy records the sale. Peregrine records which channel found the buyer. Paste one API key and each order is credited to the visit that first brought that customer, with the webhook created for you.

How it connects

  1. Add the Peregrine tag to your site. Lemon Squeezy checkout links and overlays are stamped with the visitor’s id automatically.
  2. Paste a Lemon Squeezy API key. Peregrine checks it, lists your stores and asks which one belongs to this site. A key reaches every store on the account, so skipping that question would put several shops’ revenue on one dashboard.
  3. Peregrine creates the webhook itself and reads your last 30 days of orders. You never register a URL or copy a signing secret.

How a sale is credited

The tag adds your visitor’s id to the checkout link as checkout[custom][reference_id]. If your checkout sits on your own domain, tell the tag with data-checkout, for example data-checkout="buy.example.com:checkout[custom][reference_id]".

If you create Lemon Squeezy checkouts through the API, read the peregrine_vid cookie from the request and pass it as checkout_data.custom.reference_id. If the cookie is missing, create the checkout as before.

import { cookies } from 'next/headers';

const visitor = (await cookies()).get('peregrine_vid')?.value;

// when you create the checkout:
checkout_data: { custom: { reference_id: visitor } }

What you see

  • Which channel sent the most visitors, beside which channel earned the most money.
  • Paid orders from the moment the webhook exists, plus a backfill of the last 30 days. Backfilled orders predate the tag and show as unattributed: the money is right and the channel is blank.
  • Test-mode orders are counted and flagged, which is what makes a test purchase a useful way to check the setup.

What to know

  • Why a webhook and not a plain read: Lemon Squeezy’s API does not return the checkout reference on an order. Only the webhook delivery carries it, so the delivery attributes and the API backfills.
  • The key is stored encrypted, and it expires after a year; reconnecting replaces it.
  • An order that is still pending when it is delivered is not counted, because Lemon Squeezy sends no later update.
  • Verified end to end with a real test-mode purchase.

Questions

How do I track which channel sent my Lemon Squeezy customers?

Add the Peregrine tag to your site and paste a Lemon Squeezy API key. The tag adds the visitor’s id to your checkout link, Lemon Squeezy returns it with the order, and Peregrine credits the sale to that visitor’s first visit.

Why does Peregrine create a webhook for Lemon Squeezy?

Lemon Squeezy’s API does not return the checkout reference on an order. Only the webhook delivery carries it, so the webhook attributes the sale and the API fills in orders that came before.

Do I need to copy a signing secret or register a URL?

No. Peregrine creates the webhook for you and generates the secret itself.

Does it work with a checkout on my own domain?

Yes, with one addition: tell the tag which host and parameter to use, for example data-checkout="buy.example.com:checkout[custom][reference_id]". A custom domain is otherwise not recognised as Lemon Squeezy.

My account has several stores. Which one is counted?

Only the one you choose when you connect. A key reaches every store on the account, so Peregrine asks which store belongs to this site.

Does the Lemon Squeezy API key expire?

Yes, after a year. Reconnecting replaces it.

Also see

  • Peregrine for Polar
  • Peregrine for Dodo Payments
  • First-touch vs last-touch attribution
  • How Peregrine compares with other analytics tools

See a real dashboard in the demo, or start a free trial.

peregrine
DemoDocsIntegrationsCompareUTM builderSign in
© 2026
TermsPrivacyDPA

Contact us

Something is broken or wrong

hello@justperegrine.com
Featured onFeatured on DanielLaunchesLaunched on LaunchPanda