# Bots and AI crawlers

> See when AI assistants, search engines and model-training crawlers request your pages, by forwarding crawler requests from your server to Supametrics.

Source: https://supametrics.io/docs/bot-tracking

See when AI assistants (ChatGPT, Claude, Perplexity), search engines (Googlebot, Bingbot) and model-training crawlers (GPTBot, ClaudeBot, CCBot) request your pages.

Crawlers fetch raw HTML and never run JavaScript, so the tracking script can't see them. Your server has to forward their requests to Supametrics. The dashboard's **Bot traffic** card then shows them, kept apart from your human analytics: bot hits never count as visitors, visits or pageviews.

## Crawler categories

| Tab | Means | Examples |
| --- | --- | --- |
| **AI answers** | An assistant opened your page because someone asked it a question | ChatGPT-User, Claude-User, Perplexity-User, Gemini-Deep-Research, MistralAI-User, DuckAssistBot |
| **Indexing** | Search and answer-engine indexes | Googlebot, Bingbot, OAI-SearchBot, Claude-SearchBot, PerplexityBot, Applebot, Amazonbot, DuckDuckBot, YandexBot, Baiduspider |
| **Training** | Collecting public pages for model training | GPTBot, ClaudeBot, CCBot, Bytespider, Google-Extended, Applebot-Extended, Meta-ExternalAgent |
| **Other** | SEO tools, link previews and other known crawlers | AhrefsBot, SemrushBot, facebookexternalhit, BingPreview, GoogleOther |

The **Other** tab appears only when such crawlers show up. Requests from anything that isn't a known crawler are dropped.

## Set it up

On the dashboard, the Bot traffic card shows **No bot traffic detected yet** until the first hit arrives. Click **Set up bot tracking** to open the setup dialog. It shows your **Ingest URL** and a ready-made snippet for **Node / Express**, **Next.js**, **Cloudflare Worker** and **curl**, with your URL already filled in. The same snippets are below.

Each snippet skips ordinary visitors with a coarse pattern before sending anything, sends the crawler's request after your page has been served, and ignores failures, so it never slows your site down.

## The API

```bash
POST https://app.supametrics.io/api/bots/<site public id>
Content-Type: application/json

{ "userAgent": "...", "href": "https://yoursite.com/pricing", "statusCode": 200 }
```

- The public id is the same one as in your tracking snippet (`data-site="…"`). The **Set up bot tracking** dialog shows the full URL.
- Send one hit, or an array of up to 50. The body can be at most 16 KB.
- `statusCode` is optional (100–599). `ip` is optional: the crawler's IP, used only to verify it and never stored.
- Supametrics classifies the user agent. Anything that isn't a known crawler is dropped, and so is any `href` that isn't on your website's domain, a subdomain or one of its additional domains (any host when **Allow all domains** is on). Only the path is stored, without the query string.
- Responses: `202 {accepted, ignored, rejected}`, `400` for a malformed body, `401` for a missing or wrong bot token (see [Request authentication](#request-authentication)), `403` when a single hit's URL is on another domain (in a batch it's counted as rejected), `404` for an unknown site, `413` over 16 KB, `429` when rate limited.

`ignored` counts hits that aren't known crawlers, crawlers you switched off, unverified hits while **Verified crawlers only** is on, and hits over your plan's bot allowance. `rejected` counts URLs that aren't on your website.

Never wait for the response: send it after your page is served and ignore failures.

### Bot allowance

Bot requests don't count against your plan's event limit. They have their own allowance per billing cycle, shared by all your websites, and an add-on adds more. Hits over the allowance are answered `202` and counted as ignored, not stored. See [Plans, billing and event limits](https://supametrics.io/docs/billing).

## Node / Express

```js
// Forward crawler requests to Supametrics after the response is sent.
const AX_BOTS = 'https://app.supametrics.io/api/bots/<public id>';
const CRAWLER = /bot|crawl|spider|preview|chatgpt|claude|anthropic|perplexity|gemini|google-|googleother|meta-external|facebookexternalhit|mistralai|cohere/i;

app.use((req, res, next) => {
  const ua = req.get('user-agent') || '';
  if (CRAWLER.test(ua)) {
    res.on('finish', () => {
      fetch(AX_BOTS, {
        method: 'POST',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({
          userAgent: ua,
          href: `${req.protocol}://${req.get('host')}${req.originalUrl}`,
          statusCode: res.statusCode,
          ip: req.ip, // lets Supametrics verify the crawler; never stored
        }),
        signal: AbortSignal.timeout(2000),
      }).catch(() => {});
    });
  }
  next();
});
```

Behind a proxy, set `app.set('trust proxy', true)` so `req.protocol` is `https` and `req.ip` is the crawler's address.

## Next.js (middleware.ts)

```ts
import { NextResponse, type NextFetchEvent, type NextRequest } from 'next/server';

const AX_BOTS = 'https://app.supametrics.io/api/bots/<public id>';
const CRAWLER = /bot|crawl|spider|preview|chatgpt|claude|anthropic|perplexity|gemini|google-|googleother|meta-external|facebookexternalhit|mistralai|cohere/i;

export function middleware(req: NextRequest, event: NextFetchEvent) {
  const ua = req.headers.get('user-agent') ?? '';
  if (CRAWLER.test(ua)) {
    event.waitUntil(
      fetch(AX_BOTS, {
        method: 'POST',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ userAgent: ua, href: req.url, ip: req.headers.get('x-forwarded-for')?.split(',')[0]?.trim() }),
        signal: AbortSignal.timeout(2000),
      }).catch(() => {}),
    );
  }
  return NextResponse.next();
}

export const config = { matcher: ['/((?!_next/|api/|favicon.ico).*)'] };
```

Middleware runs before the page, so it can't report the status code.

## Cloudflare Worker

```js
const AX_BOTS = 'https://app.supametrics.io/api/bots/<public id>';
const CRAWLER = /bot|crawl|spider|preview|chatgpt|claude|anthropic|perplexity|gemini|google-|googleother|meta-external|facebookexternalhit|mistralai|cohere/i;

export default {
  async fetch(request, env, ctx) {
    const response = await fetch(request);
    const ua = request.headers.get('user-agent') || '';
    if (CRAWLER.test(ua)) {
      ctx.waitUntil(
        fetch(AX_BOTS, {
          method: 'POST',
          headers: { 'content-type': 'application/json' },
          body: JSON.stringify({
            userAgent: ua,
            href: request.url,
            statusCode: response.status,
            ip: request.headers.get('cf-connecting-ip') ?? undefined,
          }),
        }).catch(() => {}),
      );
    }
    return response;
  },
};
```

## Any other backend (curl)

Send the same JSON from PHP, Python, Go or Rails. To check the setup, send one test hit:

```bash
curl -X POST 'https://app.supametrics.io/api/bots/<public id>' \
  -H 'content-type: application/json' \
  -d '{"userAgent":"Mozilla/5.0 (compatible; GPTBot/1.2; +https://openai.com/gptbot)","href":"https://yoursite.com/pricing","statusCode":200}'
```

The answer should be `202 {"accepted":1,"ignored":0,"rejected":0}`, and GPTBot appears under **Training** on the dashboard.

## The Bot traffic card

The card is titled **Bot traffic**, with "crawler requests to your pages · not counted as visitors". It follows the dashboard's period; dashboard filters (country, page, source…) apply to human visits only and don't change it.

- **Tabs**: **AI answers**, **Indexing**, **Training** (and **Other** when present), each with its number of requests. The card opens on the first tab with traffic.
- **Chart**: requests over the period, one line per crawler (up to 8). Hover for each crawler's count per bucket.
- **N crawlers**: a menu of the tab's crawlers with their request counts. Untick crawlers to take them off the chart; **Select all** puts them back. This changes the chart only, not what is stored.
- **Crawler chips** under the chart: click one to show its details in the side panel.
- **Group by pages** (the layers button): switches the chart to one line per page, for the 8 most requested pages in the tab. Click it again to group by crawlers.
- **Side panel**: the selected crawler, with "N crawls · period · tab" and its most requested pages (up to 20), searchable with **Filter pages**. Grouped by pages, it lists the top pages instead, and selecting a page names the crawlers that requested it.
- **Crawler files**: requests for `robots.txt`, `llms.txt`, `llms-full.txt` and sitemaps.
- **Settings** opens the settings (see below), and **Hide card** hides the card.

The line under the card says how crawlers were identified: by user agent only, how many requests were IP-verified, or that **Verified crawlers only** is on.

If crawlers have visited before but not in the selected period, the card says **No bot traffic in this period**.

### Preview and hiding

- **Preview with sample data** shows the full card with made-up numbers, under a banner saying **Sample data — not your website's traffic.**, with **Set up bot tracking** and **Exit preview**.
- **Hide this card** (or **Hide card**, or **Hide bot traffic card** in settings) hides the card for everyone on the website. A line at the bottom of the dashboard then says **Bot traffic card hidden.** with **Show it again**. The same switch is in **Site settings › Dashboard › Bot traffic card**. See [Dashboard settings](https://supametrics.io/docs/settings-dashboard).
- Viewers can't change website settings, so when a viewer hides the card it is hidden on their device only.

## Bot traffic settings

Click the sliders button (or **Settings**) on the card to open **Bot traffic settings**. Every switch saves at once, for everyone on the website. The owner and members can change them; viewers see them read-only.

### Verified crawlers only

User agents are easy to fake. When a hit carries `ip`, Supametrics checks it the way the crawler's operator documents: reverse DNS plus a forward lookup for Google, Microsoft (Bing), Apple, Amazon, Yandex, Baidu and Huawei, and the published IP ranges for OpenAI and Perplexity. Other crawlers can't be verified.

With **Verified crawlers only** on, only hits whose IP checks out are stored. Your integration must send each crawler's `ip`, and crawlers that can't be verified are not stored while it's on.

### Crawler ingestion

A list of crawler companies (OpenAI, Anthropic, Google, Microsoft, Perplexity…), with a badge saying how many are off. Switch a company off to stop storing all its crawlers, or expand it to switch single agents. Each agent shows its kind (**AI assistant**, **Search index**, **AI training** or **Web crawler**), a one-line description and **IP-verifiable** where it can be verified. Requests from switched-off crawlers are answered but not stored.

### Request authentication

Anyone who knows your public id could send fake bot hits. A private token stops that:

1. Click **Create token**. The token (starting `axbot_`) is shown once: copy it then.
2. Store it on your server, for example in an environment variable `AX_BOT_TOKEN`, never in client code.
3. Send it with each request as `Authorization: Bearer <token>` (or `X-Supametrics-Token: <token>`). With a token, the setup dialog's snippets already include this header.
4. Turn on **Reject unauthenticated requests** to refuse requests that don't send a token.

A wrong or old token is always refused with `401`. **Rotate** makes a new token and stops the old one at once. **Delete** removes the token; requests without a token are accepted again, and requests still sending the old one are refused.

### Install guide and hiding

**Install guide** opens the setup dialog with the snippets. **Hide bot traffic card** hides the card (see above).

## Common questions

**Why don't crawlers show up in my visitor numbers?** They're kept separate on purpose. Crawlers that do run JavaScript are filtered out of normal tracking too.

**I sent a hit and got `ignored: 1`.** The user agent isn't a known crawler, the crawler is switched off, **Verified crawlers only** is on and the IP didn't verify, or your account has used its bot allowance for this cycle.

**Is the crawler's IP address stored?** No. It's used only for verification.
