# Lemon Squeezy

> Connect Lemon Squeezy to atrby so each order and subscription payment is matched to the visit that brought it.

Canonical: https://atrby.site/docs/integrations/lemon-squeezy
Last updated: 2026-10-21

Attribute every Lemon Squeezy payment to the visit that brought it.

## Connect

1. In Lemon Squeezy, open Settings → Webhooks → add a webhook. You choose the **Signing secret** there yourself; paste the same value into atrby.
2. In atrby, open Revenue → Payment processors → Connect, choose Lemon Squeezy and paste the secret.
3. atrby shows your webhook URL. It looks like `https://app.atrby.site/api/webhooks/lemonsqueezy/…`. Add it in Lemon Squeezy and send these events: `order_created`, `subscription_created`, `subscription_payment_success`, `order_refunded`.

The connection shows as active once the first webhook arrives. Webhooks with a wrong signature are rejected.

## Pass the visit ids

Where they go: Checkout `checkout_data.custom`. Lemon Squeezy returns it as `meta.custom_data` on orders and subscription payments. Read them in the browser with `atrby.ids()` and send them to your server with the checkout request.

*Browser*

```js
const ids = window.atrby?.ids(); // { atrby_sid, atrby_site }
```

*Server · Lemon Squeezy checkout*

```js
await createCheckout(storeId, variantId, {
  checkoutData: {
    custom: { ...ids, atrby_uid: user.id },
  },
});

// Or on a checkout link:
// https://acme.lemonsqueezy.com/buy/…?checkout[custom][atrby_sid]=…&checkout[custom][atrby_site]=…
```

`atrby_uid` is your user id, from [identify](https://atrby.site/docs/identify). It's optional, but it credits payments made long after the first visit.

## What gets recorded

- Each payment once, however often Lemon Squeezy retries the webhook.
- Full and partial refunds are subtracted from the source of the original order.
- `subscription_payment_success` is only used for renewals; the first payment comes from `order_created`.

## Related
- [Stripe](https://atrby.site/docs/integrations/stripe)
- [Polar](https://atrby.site/docs/integrations/polar)
- [Payment API](https://atrby.site/docs/payment-api)
