# Connect Polar: setup guide

Add a Polar webhook for paid, updated and refunded orders, paste its secret, and see how revenue, renewals and refunds from Polar are counted.

This is the setup. What attribution gives you with Polar, and how checkout links and the Checkout API compare, is on the [Polar revenue attribution page](https://supranalytics.app/integrations/polar).

**1. Add a webhook endpoint in Polar**

In Polar, Settings → Webhooks → Add Endpoint. Choose the **Raw** format and this URL (your website id is in Settings → General):

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

Select the events `order.paid`, `order.updated` and `order.refunded`.

**2. Paste the secret in SuprAnalytics**

Copy the endpoint's secret (`whsec_…`) into Settings → Revenue with Polar selected, and save.

**3. Pass the visitor id**

[Checkout links](https://supranalytics.app/docs/polar-checkout-links.md) need nothing. For [checkouts created on your server](https://supranalytics.app/docs/polar-checkout-api.md), add the visitor id as metadata.

## What SuprAnalytics counts

- **Revenue** is the order's `net_amount`: after discounts, before tax. Polar is the merchant of record, so tax isn't your revenue. Free orders are skipped.
- **Renewals** (billing reasons `subscription_cycle`, `subscription_update` and `subscription_meter_cycle`) are marked as renewals and credited to the customer's original visitor.
- **Refunds**: a full refund marks the payment refunded; a partial one lowers its amount.
- **Retries** are safe: each order is stored once.
- Signatures follow Standard Webhooks and are checked against your secret; both Polar secret formats work.

> **Testing**
>
> Test on a second website, not your real one: each website keeps one Polar secret, and test payments sent to a real website stay in its revenue (payments can't be deleted). Add a website for your staging site (websites are unlimited), with its own script, point a webhook in Polar's **sandbox** at that website's URL, paste the sandbox's secret into that website's Settings → Revenue, and pay with a test card.

---

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