Skip to main content
AI crawlers such as GPTBot, ClaudeBot and PerplexityBot request your pages but never run JavaScript, so the CrispStats script cannot see them. To count them, post each crawler request from your server, middleware or edge to the collector’s /bot endpoint. The hits then appear in the AI crawlers section of the AI traffic screen. There is no package to install: the code below uses fetch and nothing else.

What gets sent

One small request to https://in.crispstats.com/bot with four fields: your public key, the User-Agent, the URL’s path and the response status. No IP address, no query string, no cookies and no other headers. The code checks the User-Agent first, so requests from anything that is not a known AI crawler make no network call. The call never throws into your request: errors are swallowed. Do not await it in the request path; hand the promise to waitUntil so the response is not delayed.

Set it up

1

Report crawler requests

Use your site’s public key, the cs_pk_ key from Settings, Tracking code. The same code, with your key filled in, appears in the AI crawlers section of the AI traffic screen until the first hit arrives.
Add the call to proxy.ts at the root of your project, next to app (or inside src if you use one). Before Next.js 16 the file is middleware.ts and the exported function is named middleware.
proxy.ts
If you already have a proxy.ts, add the if block to your existing function and keep your own return value. If you proxy the script through a path on your site, leave that path out of the matcher too. The proxy runs before the page is rendered, so it does not know the final status: every hit is reported as 200.
Replace cs_pk_xxxxxxxx with your key. The public key is safe to use here; never use a secret cs_sk_ key.
2

Deploy and confirm

Deploy the change and wait for a crawler to visit, or send a test request with a crawler’s User-Agent:
Open AI traffic in the dashboard. The AI crawler hits chart replaces Not set up with a count, and GPTBot appears in the AI crawlers table.
The pattern above is the list of recognized crawlers. If you would rather let the collector decide, post every request: the collector stores only known AI crawlers, at the cost of one request to the collector per page request.

The /bot request

From any language, send the same request: POST https://in.crispstats.com/bot with a JSON body.
string
required
The site’s public key, 4 to 64 characters.
string
required
The request’s User-Agent, up to 1,024 characters.
string
required
The requested path, up to 2,048 characters. A full URL is accepted too. The collector drops the query string and fragment, removes a trailing slash and stores at most 1,024 characters of the path.
number
default:"200"
The response status, an integer from 100 to 599.
The collector answers 202 with an empty body as soon as the payload is valid, and does the work afterwards. It answers 400 with {"error":"invalid_payload"} when a field is missing or out of range, and 413 with {"error":"payload_too_large"} for a body over 16 KB. A 202 does not mean the hit was stored. The collector silently ignores a hit when the User-Agent is not a known AI crawler, the key does not belong to a site, the site is blocked, or the site is over its per-site rate limit for crawler hits.

Recognized crawlers

The collector matches each User-Agent against this list, case-insensitively, as a substring. The Purpose column is what the dashboard shows next to each crawler. The purposes mean:
  • Training: collects pages to train AI models.
  • Search: indexes pages so an AI search product can cite them.
  • User-triggered: fetches a page because someone asked an assistant about it.

Crawlers never count as visitors

If an AI crawler does load the script, for example through a headless browser, the collector drops that event. AI crawlers are excluded from pageviews and visitors at every bot filtering level, including off: they are counted only through /bot.

Learn more on crispstats.com

Next steps

See AI traffic

Read crawler hits next to the visitors AI assistants send you.

Bot filtering

How other bots and automated browsers are kept out of your numbers.

Server-side events

Send custom events and revenue from your server.
Last modified on November 23, 2026