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

# Install CrispStats with an AI coding agent

> Hand the CrispStats install to Claude Code, Cursor, Codex or another coding agent: one prompt written for your site, a plain-text install guide the agent reads, and MCP tools that let it check its own work.

A coding agent can install CrispStats in one pass: the script in the right place for your framework, a proxy that never forwards your visitors' cookies, the visitor id in your checkout metadata, and a check that it all works. The dashboard writes the prompt for your site, so the agent does not have to guess your key, your hostnames or your proxy path.

## Copy the prompt

**1. Open the install step**

In the dashboard, open **Settings**, **Tracking code**, or the install step when you add a site. The first block is **Set up with an AI agent**.

**2. Copy the prompt**

Select **Copy prompt** and paste it into Claude Code, Cursor, Codex or any agent that can edit your project. **Show prompt** shows it first.

**3. Review what it changed**

The agent lists the files it changed and what the setup check returned. Review the diff like any other change, then deploy.

The prompt tells the agent, in this order, to:

1. Detect the framework and the host, and say what it found before changing anything.
2. Add only the script element, the framework's way: in Next.js one `next/script` element in the root layout, never a replaced layout. The tag carries `data-site`, `data-domains` with your hostnames and your proxy path in `data-api` and `src`. It never adds `id="crispstats"`, and adds `data-hash` only for an app that routes with `/#/` URLs.
3. Forward your proxy path to `https://in.crispstats.com/p/*` with the handler for your host, sending only `content-type`, `user-agent`, `accept-language`, `referer`, `origin`, `if-none-match` and the visitor's address. Never `cookie` or `authorization`. On hosts without server code (Webflow, Framer, Shopify) it uses the direct tag instead.
4. If the app takes payments, read `crispstats.id()` in the click handler that starts checkout and put it in the checkout's `metadata.crispstats_visitor_id`. It leaves your own `client_reference_id` alone, and asks you to connect the provider yourself, because that needs a key the agent should not handle.
5. If users sign in, call `identify()` where the session is known, and tell you that this makes the data personal data under GDPR.
6. Verify with `data-debug` locally, then with the setup check after deploying, then remove `data-debug`.

It also lists what never to do: forward cookies, keep whole query strings with `data-keep-params="*"`, keep a direct script tag on checkout pages next to the proxied one, or put a secret key in browser code. There is no npm package to install, and the prompt says so.

## The install guide

The prompt links to a plain-text guide the agent fetches first:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://crispstats.com/llms-install.txt
```

It is the full reference in Markdown: every script attribute, every collector route, the proxy handler for Next.js, Next.js on Cloudflare (OpenNext and vinext), Vercel, Netlify, Cloudflare Workers and nginx, the checkout wiring for Stripe, Lemon Squeezy, Polar, Paddle, Dodo Payments, Creem, Razorpay and RevenueCat, the setup check's fields and the never list. It is built from the same code as the snippets in the dashboard, so the two cannot disagree.

Without a query string the guide uses placeholders such as `cs_pk_your_site_key`. The link in your prompt adds your site's values:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://crispstats.com/llms-install.txt?k=cs_pk_xxxxxxxx&d=example.com,www.example.com&p=/k3x9qe
```

| Parameter | Value |
| - | - |
| `k` | The site's public key. |
| `d` | The hostnames for `data-domains`, comma-separated. The first is the site's domain. |
| `p` | The proxy path. |
| `keep` | Query parameters the site keeps beyond the defaults (`data-keep-params`). Optional. |
| `persist` | `1` when persistent visitors is on. Optional. |

Every value is public already (the key and hostnames are in your pages' HTML) and is checked against a strict pattern, so a crafted link cannot put other text into the guide.

## Let the agent check its own work

Connect the agent to the [MCP server](https://docs.crispstats.com/api-reference/mcp.md) with a read-only key, as in [connect AI assistants](https://docs.crispstats.com/ai/connect-ai-assistants.md). It then has three setup tools and three prompts:

| Tool | What it returns |
| - | - |
| `get_install_guide` | For a `framework` and `host`, the exact script element, the proxy handler and the steps, with your key, hostnames and proxy path. |
| `check_installation` | Whether events arrived in the last `minutes`, from which hostnames, whether the collector knows the key, and through your proxy path whether the visitor's address arrives, whether cookies leak and whether requests are signed. Each problem comes with its fix. |
| `get_revenue_setup` | For a payment `provider`, where the visitor id goes and the code that puts it there, how the owner connects the provider with a key (which key, where to create it, which permissions), how to check it, and whether it is connected already. |

| Prompt | What it does |
| - | - |
| `install_crispstats` | The same prompt as the dashboard's, plus the instruction to use the tools above. |
| `connect_payments` | Wires the visitor id into checkout for one provider. |
| `explain_last_week` | Reads last week against the week before and explains what changed. |

In Claude Code, prompts appear as slash commands, for example `/mcp__crispstats__install_crispstats`.

## Check it yourself

The setup check answers in your browser too. Open your proxy path's check on your live site:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
https://example.com/k3x9qe/check?k=cs_pk_xxxxxxxx
```

Look for `"ok": true`, `"visitorAddressForwarded": true` and `"cookiesForwarded": false`. The [proxy guide](https://docs.crispstats.com/tracking/proxy.md) explains every field.

## Next steps

> [card] [Next.js](https://docs.crispstats.com/install/nextjs.md)
>
> The script element, types and the route handler, by hand.

> [card] [Proxy the script](https://docs.crispstats.com/tracking/proxy.md)
>
> Every host's handler and the setup check.

> [card] [Visitor id at checkout](https://docs.crispstats.com/revenue/visitor-id-at-checkout.md)
>
> How payments are attributed.


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