> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crispstats.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> CrispStats is a hosted, privacy-first web analytics product. It has no self-hosted edition, no session replay, no heatmaps, no A/B testing, no mobile SDKs and no data import except a site's history from a Plausible export (Settings, Import and export).
> The script global is crispstats(...), site keys start with cs_pk_ and secret API keys start with cs_sk_. The script is served from https://in.crispstats.com/d.js and the REST API lives at https://crispstats.com/api/v1.
> There is no npm package to install. Integrations copy the script tag, the queue stub, crispstats.d.ts and proxy code from these docs or from Settings, Tracking code in the dashboard. A first-party proxy forwards one path of the site to https://in.crispstats.com/p/ and forwards only content-type, user-agent, accept-language, referer, origin, if-none-match and x-forwarded-for, never cookies.

# Connect Paddle revenue to CrispStats

> Connect Paddle Billing with an API key: choose the products that count, and CrispStats imports past transactions, records new ones and ties each to a visit through customData.

Connect Paddle Billing by pasting an API key and choosing which products count for this site. CrispStats imports your past transactions and refunds, creates its own notification destination when the key allows it, and records transactions, renewals, refunds and chargebacks from then on. Put the visitor id in the checkout's `customData` and each transaction is tied to the visit that led to it.

| | |
| - | - |
| You paste | A Paddle Billing API key, then choose the products that count |
| New payments | Within seconds when the key may write notification settings, otherwise within 5 minutes |
| History | Every transaction since your first |
| Test mode | A sandbox key (`pdl_sdbx_apikey_`) connects in test mode |
| Linked to a visit | When `crispstats_visitor_id` is in the checkout's `customData` |

## What is recorded

| Paddle object | Recorded as |
| - | - |
| A completed transaction with a total above zero | `subscription_renewal` when its `origin` starts with `subscription_`, `subscription_new` when it has a `subscription_id`, otherwise `one_time` |
| An approved refund or chargeback adjustment | `refund`, for the adjustment's total. One created as pending is recorded when Paddle approves it. |

Only transactions of the products you selected count. Every transaction is read back from Paddle's API with your key before it counts as verified revenue.

> [!WARNING]
>
> Paddle's events and transactions do not include the customer's email, so Paddle payments show **No e-mail** in the payments table. A renewal or refund is linked to a visit only when its own `custom_data` carries the visitor id or a user id.

## Connect Paddle

**1. Open the Paddle panel**

In CrispStats, open the site's **Settings**, then **Integrations**. Select **Connect a payment provider** and choose **Paddle**.

**2. Create the API key**

Under **Paddle API key**, select **Create an API key in Paddle**. Then:

1. Choose **New API key** and name it CrispStats.
2. Leave **Expires** empty so the key never expires.
3. Turn on **Read** for **Transactions**, **Adjustments** and **Products**.
4. Turn on **Write** for **Notification settings** so sales show up the moment they happen.
5. Copy the key and paste it here.

Use a key from Paddle Billing, not Paddle Classic.

**3. Paste the key and choose products**

Paste the key. CrispStats checks it with Paddle and lists your active products under **Products that count**, all ticked. Only selected products count toward this site's revenue. Untick the ones sold on another site.

**4. Connect**

Select **Connect Paddle**. The row shows **Connected. Live. Counting** the number of selected products. Without **Notification settings: Write** it says "Updates every 5 minutes. Add Notification settings to the key to see sales the moment they happen."

**5. Pass the visitor id at checkout**

See [pass the visitor id at checkout](#pass-the-visitor-id-at-checkout) below.

What the panel refuses:

* A notification secret key (`pdl_ntfset_`): paste an API key instead.
* A Paddle Classic vendor ID or auth code: CrispStats works with Paddle Billing, so create the key in your Paddle Billing dashboard.
* A key without **Transactions: Read** or **Adjustments: Read**: the message names the permission to turn on.

Keys made before 6 May 2025 are 50 lowercase letters and digits and have full access. They still connect, with the line "This is an older Paddle key with full access. Create a new key with only the permissions above when you can."

To change which products count later, choose **Change products** on the row. The change applies to payments recorded from then on. To apply it to past payments too, choose **Import again**: CrispStats removes the stored sales of products no longer selected, with their refunds, then imports again. Sales stored before CrispStats kept product ids are never removed.

## What the key can do

| Permission | Why |
| - | - |
| Transactions: Read | Read and verify each transaction, past and new |
| Adjustments: Read | Refunds and chargebacks are adjustments in Paddle. Without it refunds could not be counted |
| Products: Read | List your products so you can choose which count |
| Notification settings: Write | Create the notification destination, and delete it when you disconnect. Optional: without it CrispStats checks every 5 minutes |

CrispStats does not ask for Customers or Subscriptions: transactions say whether they are new or a renewal, and customer records are not needed. It never moves money.

A key you set to expire is still handled: Paddle tells CrispStats seven days before, and the row asks for a new key. A key that stops working shows "Paddle no longer accepts the saved key. It expired or was revoked. Create a new one and paste it here."

## How fresh the numbers are

With **Notification settings: Write**, Paddle sends each transaction within seconds, and CrispStats checks every 30 minutes as a safety net. Without it, CrispStats reads new transactions and adjustments every 5 minutes.

Paddle limits API calls per IP address, and CrispStats' servers share addresses with other services. If Paddle asks CrispStats to slow down, every Paddle connection pauses for a minute, so a check can occasionally run later than 5 minutes. The row's **Updated** time always shows the last successful check.

## Past payments

When you connect, CrispStats imports every completed transaction and approved adjustment of the selected products. See [revenue history](https://docs.crispstats.com/revenue/history.md).

## Test mode

A sandbox key starts with `pdl_sdbx_apikey_` and connects to Paddle's sandbox. The panel says "This is a test key. Test payments show with a Test tag and never count as verified revenue." and offers **Connect in test mode** or **Use a live key**. The help card's link has a sandbox version.

## Pass the visitor id at checkout

Add the id from `crispstats.id()` to the checkout's `customData` as `crispstats_visitor_id`:

```js theme={"theme":{"light":"github-light","dark":"github-dark"}}
// In the browser, before you open the checkout
const visitorId = await crispstats.id();

Paddle.Checkout.open({
  items: [{ priceId: "pri_123", quantity: 1 }],
  customData: visitorId ? { crispstats_visitor_id: visitorId } : undefined,
});
```

If you create transactions on your server, put the same key in the transaction's `custom_data`. A transaction without it is still recorded and counted, without a visit.

## Disconnect

Select **Disconnect** on the Paddle row. CrispStats deletes its notification destination in Paddle while the key still works, then destroys the saved key and secret. Payments already recorded stay.

Paddle keeps sending to a destination even after the key that made it is deleted. If CrispStats could not delete it, the message says "Delete the CrispStats notification destination in Paddle yourself: it keeps sending even after the key is deleted." Do that under **Developer tools**, then **Notifications**.

> [!NOTE]
>
> Connections made earlier by pasting a notification secret key keep working. They cannot import history or verify payments: connect again with a key to add both.

## Next steps

> [card] [Attribute across days](https://docs.crispstats.com/revenue/visitor-id-at-checkout.md#attribute-across-days-with-your-user-id)
>
> Pass your user id so renewals reach the right first visit.

> [card] [Refunds and renewals](https://docs.crispstats.com/revenue/refunds-and-renewals.md)
>
> How payment kinds are recorded across providers.

> [card] [Revenue history](https://docs.crispstats.com/revenue/history.md)
>
> What the import reads and how it avoids counting twice.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.