# Connect Lemon Squeezy: setup guide

Add a Lemon Squeezy webhook with a signing secret, pass the visitor id as checkout custom data, and see how orders, renewals and refunds are counted.

This is the setup. What attribution gives you with Lemon Squeezy, from revenue by source to renewals and refunds, is on the [Lemon Squeezy revenue attribution page](https://supranalytics.app/integrations/lemon-squeezy).

**1. Add a webhook in Lemon Squeezy**

In Settings → Webhooks, add this URL with a signing secret of your choice:

```
https://supranalytics.app/api/webhooks/lemonsqueezy/YOUR_WEBSITE_ID
```

Select `order_created`, `subscription_payment_success`, `order_refunded` and `subscription_payment_refunded`.

**2. Paste the same secret in SuprAnalytics**

In Settings → Revenue with Lemon Squeezy selected.

**3. Pass the visitor id as custom data**

On checkout links, add `checkout[custom][supr_visitor_id]`:

```
<script>
  document.addEventListener("click", function (e) {
    var link = e.target.closest && e.target.closest('a[href*=".lemonsqueezy.com/checkout"]');
    if (!link || !window.supr || !window.supr.visitorId) return;
    var url = new URL(link.href);
    url.searchParams.set("checkout[custom][supr_visitor_id]", window.supr.visitorId());
    link.href = url.toString();
  }, true);
</script>
```

Creating checkouts with the API? Put it in `checkout_data.custom.supr_visitor_id`.

## What SuprAnalytics counts

- Paid orders, for their `total`.
- Subscription payments with the billing reason `renewal`, as renewals. The first payment is the order itself.
- Refunded orders and subscription payments are marked refunded.

---

This page on the web: https://supranalytics.app/docs/lemonsqueezy
Every documentation page: https://supranalytics.app/docs.md
