> ## 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 Whop revenue to CrispStats

> Connect Whop with a company API key and company ID: CrispStats imports past payments, creates its webhook when the key allows it, and ties each sale to a visit through checkout metadata.

Connect Whop by pasting an API key and your company ID. CrispStats imports your past payments, creates its own webhook when the key allows it, and records one-time payments, new memberships, renewals, refunds and lost chargebacks from then on. Put the visitor id in the checkout's metadata and each sale is tied to the visit that led to it.

| | |
| - | - |
| You paste | A Whop API key with custom permissions, and your company ID (`biz_`) |
| New payments | Within seconds when the key may manage webhooks, otherwise within a minute |
| History | Every payment since your first |
| Test mode | A key from Whop's sandbox connects in test mode |
| Linked to a visit | When `crispstats_visitor_id` is in the checkout configuration's `metadata` |

## What is recorded

| Whop object | Recorded as |
| - | - |
| A paid payment | `billing_reason` sets the kind: `subscription_create` is `subscription_new`, `subscription_cycle` and `subscription_update` are `subscription_renewal`, `one_time` and `manual` are `one_time` |
| A succeeded refund | `refund` of its payment, one per refund, partial or full |
| A chargeback the company lost | `refund` of the disputed payment. Open, won and prevented disputes change nothing |

The amount is the payment's total after discounts, tax included, in the payment's currency. Every payment is read back from Whop's API with your key before it counts as verified revenue.

Sales from Whop's own pages are counted without a visit: only checkouts that start on your site can carry the visitor id.

## Connect Whop

**1. Open the Whop panel**

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

**2. Create the API key**

Under **Whop API key**, select **Open the Whop developer dashboard**. Then:

1. Under **Account API keys**, choose **Create**.
2. Name it CrispStats and choose custom permissions.
3. Tick **Read payments**, **Read disputes** and **Manage webhooks**.
4. Copy the key and paste it here.

**3. Paste the company ID**

Under **Company ID**, paste your company ID. It starts with `biz_` and is in the address bar of your Whop dashboard (the **Open your Whop dashboard** link). You can paste the whole address: CrispStats keeps only the ID.

**4. Connect**

CrispStats checks the key against the company at once. Select **Connect Whop**.

With **Manage webhooks**, CrispStats creates one webhook for the company and the row shows **Connected. Live.** Without it, the row says "Updates every minute. Add Manage webhooks 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.

If the key cannot read the company's payments, the panel says "This key cannot read payments for" your company ID, "Check the company ID, or add Read payments to the key." A company ID pasted into the key field, or another provider's key, is refused with a message saying which field it belongs in.

> [!NOTE]
>
> Whop's documentation names these permissions `payment:basic:read`, `payment:dispute:read` and `developer:manage_webhook`. The labels in Whop's permission picker may read slightly differently from the ones above. Whop does not document a prefix for API keys, so the panel checks only that the key is at least 24 characters with no spaces.

## What the key can do

| Permission | Why |
| - | - |
| Read payments | Read and verify each payment and refund, past and new |
| Read disputes | Take lost chargebacks off revenue. Without it payments and refunds still count, and the row says lost chargebacks are not taken off |
| Manage webhooks | Create the webhook, and delete it when you disconnect. Optional: without it CrispStats checks every minute |

Whop advises a custom permission set over an Admin key, and so does CrispStats: an Admin key could move money. CrispStats does not ask to read your company's name, so the row may show **Connected** without it. It never moves money.

## How fresh the numbers are

With **Manage webhooks**, Whop sends each payment within seconds, and CrispStats checks every 15 minutes as a safety net. Without it, CrispStats reads new payments and refunds every minute.

## Past payments

When you connect, CrispStats imports every paid payment and refund of the company since your first. See [revenue history](https://docs.crispstats.com/revenue/history.md).

## Test mode

Whop's sandbox keys look the same as live keys. CrispStats tries Whop's live API first and the sandbox second; a key only the sandbox accepts gets "This is a test key. Test payments show with a Test tag and never count as verified revenue." and the choice of **Connect in test mode** or **Use a live key**. Sandbox keys are made at `sandbox.whop.com/dashboard/developer`.

## Pass the visitor id at checkout

Create a checkout configuration on your server with the visitor id in its `metadata`, then send the visitor to its purchase URL. Whop's documentation says payments made from a checkout configuration inherit its metadata.

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

// On your server, with your own Whop API key
const response = await fetch("https://api.whop.com/api/v1/checkout_configurations", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.WHOP_API_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    mode: "payment",
    plan_id: "plan_...",
    metadata: { crispstats_visitor_id: visitorId },
  }),
});
const { purchase_url } = await response.json();
// Send the visitor to purchase_url
```

Use your own server key here, with the permission Whop asks for to create checkouts, not the key you gave CrispStats. Whop's own tracking id (`wuid`) is never read as a visitor id. A payment without `crispstats_visitor_id` is still recorded and counted, without a visit.

## Disconnect

Select **Disconnect** on the Whop row. CrispStats deletes its webhook in Whop and destroys the saved key and signing secret. Payments already recorded stay. If Whop does not let CrispStats remove the webhook, delete the one named CrispStats revenue attribution in Whop, under **Developer**, then **Webhooks**.

## Next steps

> [card] [Pass the visitor id](https://docs.crispstats.com/revenue/visitor-id-at-checkout.md)
>
> When there is no id, and attributing across days.

> [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.