Sign inGet started
Tracking

AI crawlers

View as MarkdownOpen in ChatGPTOpen in Claude
Connect your agent
Add to CursorAdd to VS Code

Count the requests of ChatGPT, Claude, Perplexity and other AI crawlers to your site with a Cloudflare Worker, and see which pages they read.

Updated

An AI crawler is a bot that reads your pages for an AI company: to train a model, to build a search index for answers, or to fetch a page because a person asked an assistant about it. It never runs the tag, so the tag can't see it. Your server sees it, so a sender on your server tells nextanalytica.

With a sender in place, your agent reads which bots came, which pages they read, and whether each one is who it says it is.

What does a sender do?

For every request to your site, the sender looks at the user agent, the bot's name in the request. If it's the name of an AI crawler on the list below, the sender passes one hit to https://t.nextanalytica.app/b after your site has answered. Every other request is never sent.

Use one sender per site. Two senders on the same site, the Worker and the WordPress plugin for example, each send the same request, so every hit counts twice.

BotOwnerWhy it reads
ChatGPT-UserOpenAIA person asked ChatGPT about a page
OAI-SearchBotOpenAIBuilds ChatGPT's search results
GPTBotOpenAITrains models
Claude-UserAnthropicA person asked Claude about a page
Claude-SearchBotAnthropicBuilds Claude's search results
ClaudeBotAnthropicTrains models
Perplexity-UserPerplexityA person asked Perplexity about a page
PerplexityBotPerplexityBuilds Perplexity's search results
Meta-ExternalFetcherMetaA person asked a Meta assistant about a page
Meta-ExternalAgentMetaTrains models
MistralAI-UserMistralA person asked a Mistral assistant about a page
DuckAssistBotDuckDuckGoFetches a page live for an AI answer
AmazonbotAmazonImproves Amazon's products and may train its models
BytespiderByteDanceTrains models
CCBotCommon CrawlAn open crawl others use to train models

What is sent and what isn't?

SentNever sent or never kept
The time, your host, the path without its query, and the status your site answeredCookies, request headers and page content
The bot's user agent, to name itAny request from a person or another bot
The connecting IP address, to check the bot (see below)The IP address after the check: nextanalytica never stores it

nextanalytica keeps the bot's name, its owner and purpose, the host, the path, the status and the check's result. The path is cleaned like the tag's: emails and long ids are removed. The user agent isn't kept.

A crawler hit is not a visit. It belongs to no person and no session, and it is never counted in your visits, pages or channels.

How do I set up the Cloudflare Worker?

You need your site's DNS on Cloudflare with the record proxied (the orange cloud), and a server key. For the key, see What do you need? on the Segment and RudderStack page; it's the same key. Your agent can also make one with make_server_key.

  1. In a new folder, install the package with pnpm add @nextanalytica/tag wrangler.
  2. Create src/worker.ts with the line below. It re-exports the sender, which is already a complete Worker.
  3. Create wrangler.toml with the name of your Worker, main = "src/worker.ts" and a compatibility_date of today.
  4. Run pnpm wrangler deploy.
  5. Store your server key as a secret: run pnpm wrangler secret put NEXTANALYTICA_SERVER_KEY and paste the key.
  6. In the Cloudflare dashboard, open Workers & Pages, select your Worker, then Settings > Domains & Routes > Add > Route. Pick your zone and enter example.com/* with your own domain. Then set the route's failure mode to fail open, as described under the free plan's request limit in Cloudflare's Workers limits.

The file src/worker.ts:

src/worker.ts
export { default } from "@nextanalytica/tag/cloudflare/crawlers";

The Worker returns your site's response as it is. It sends the hit after the response, without making anyone wait, and gives up after 1 second. If the send fails, nothing happens to your site, and if the Worker itself fails, the request goes on to your site as if the Worker weren't there.

How do I set up WordPress?

The nextanalytica WordPress plugin (1.2.0 and later) can send the hits itself. For the plugin itself, see WordPress and WooCommerce. To send crawler hits:

  1. In WordPress, open Settings > nextanalytica.
  2. Under Server key (optional), paste your server key (see What do you need? on the Segment and RudderStack page) and select Save. From a terminal or an agent: wp nextanalytica server-key nask_….

The key is saved on your server only. The page never shows it again in full, and an empty field keeps the saved key. On a WooCommerce store, the same key also sends the orders the browser can't. Like those orders, crawler hits pause on a copy of the site at another address. The plugin sends the hit after WordPress has answered, and only for an AI crawler's request, so people never wait for it. When PHP runs under PHP-FPM or LiteSpeed, the plugin finishes the bot's response before sending. Elsewhere the bot's own response can wait up to half a second, the send's time limit.

The plugin sends the address WordPress sees. When that address is one of Cloudflare's own, the plugin sends the bot's address from Cloudflare's CF-Connecting-IP header instead, so the check works behind Cloudflare too. Behind another proxy or load balancer, WordPress sees the proxy's address, the check can't match the owner's list and the hit is stored as unverified.

How do I set up Next.js?

In your app's middleware.ts, call sendCrawlerHit. You need a server key (see What do you need? on the Segment and RudderStack page).

  1. Install the package with pnpm add @nextanalytica/tag.
  2. Store your server key as the environment variable NEXTANALYTICA_SERVER_KEY on your host.
  3. Add the call to middleware.ts, as below. Pass the key from your own middleware.ts: Next.js gives middleware the environment variables it finds written in your code, and on Vercel's Edge runtime a read from inside a package may not be one of them.
middleware.ts
import { NextResponse, type NextFetchEvent, type NextRequest } from "next/server";
import { sendCrawlerHit } from "@nextanalytica/tag/next/crawlers";

export function middleware(req: NextRequest, event: NextFetchEvent) {
  sendCrawlerHit(req, event, { serverKey: process.env.NEXTANALYTICA_SERVER_KEY });
  return NextResponse.next();
}

The sender sends the hit after your response, without making anyone wait, and gives up after 1 second. If the send fails, nothing happens to your site.

The address it sends depends on your host. On Vercel and Netlify it sends the address the platform itself sets. Anywhere else it sends none, so the hits are stored as unknown. It never sends x-forwarded-for: wherever a proxy adds to that header, a client can write its first address, and a fake bot could borrow an owner's address. If you host the app yourself behind a proxy that overwrites a header with the client's address, pass that header with the ip option, for example ip: (req) => req.headers.get("x-real-ip") ?? undefined. Only do this when your proxy overwrites the header, never when it adds to it.

To send for some paths only, set a matcher in middleware.ts. A page served from a CDN cache may never reach your middleware, so a crawler that gets it isn't counted.

Does this work with Webflow?

Webflow supports Cloudflare in front of a custom domain through its orange-to-orange (O2O) setup. Follow Webflow's guide, Using Cloudflare orange-to-orange (O2O) with Webflow, to put your domain on Cloudflare. Then follow the Worker steps above for the same domain.

We haven't tested this setup ourselves.

How does nextanalytica know a crawler is real?

Anyone can write GPTBot as their user agent. So for the owners that publish the addresses their crawlers come from, nextanalytica checks the connecting IP against those lists, then drops the IP. Each hit is stored with one of three results:

ResultMeaning
verifiedThe IP is inside the owner's published addresses. The bot is who it says it is.
unverifiedThe owner publishes addresses and the IP is outside them. Most likely something pretending to be the bot.
unknownThe owner publishes no usable list, or the sender gave no IP. It can't be checked either way.

OpenAI, Perplexity and Common Crawl publish their addresses, and nextanalytica refreshes a list when a hit arrives and its copy is more than a day old, and a failed refresh keeps the last good copy. Anthropic, Meta, Amazon, Mistral, DuckDuckGo and ByteDance publish no list nextanalytica can check against, so their hits are unknown.

Why don't Gemini and Copilot show up?

Gemini and Copilot read your pages through Googlebot and Bingbot, the same bots that crawl for plain search. nextanalytica can't tell a fetch for Gemini from a fetch for Google Search, so neither bot is on the list and neither is sent.

Did a fetch lead to a visit?

When a person asks ChatGPT, Claude or Perplexity about your site, the assistant often fetches your page right then. If the person then clicks through, the visit lands in the AI assistants channel. The ai_chain block of get_dashboard joins the two: it gives every visit in the AI assistants channel that started in the period one level, the first that fits.

LevelMeaning
fetched_pageThe same assistant fetched the page the visit entered on, in the 30 minutes before the visit started.
fetched_siteThe same assistant fetched another page of your site in those 30 minutes.
ai_referredThe visit came from the assistant with no fetch by it in those 30 minutes.

The same assistant means a ChatGPT-User fetch counts for a visit from ChatGPT, a Claude-User fetch for a visit from Claude, a Meta-ExternalFetcher fetch for a visit from Meta AI, and so on. Only fetches made because a person asked count: a search or training crawl never does. A fetch checked as unverified never counts either; verified and unknown ones do.

The levels never overlap, so together they add up to the AI assistants channel's visits that started in the period. The visits metric for that channel can differ slightly: a visit that crossed midnight into the period, or a visit without a page view, can be counted by one and not the other. For each level your agent reads:

FieldWhat it is
sessionsVisits at that level.
conversionsThe visits' conversions, each counted once per visit, as in your conversions.
revenueOrders in those visits, plus Stripe payments that carry the visitor's id (see below), in your project's currency at the European Central Bank's rate of each day.

A Stripe payment counts for the person's latest visit that started before it, and only when that person sent no order in the period, so a purchase sent both as an order and through Stripe counts once. Refunds don't reduce revenue, as in the revenue metric. Conversions and orders after the period's last day aren't counted, so a visit that started near the end of the period may have more than its level shows.

The block also has:

  • routes: up to 20 pages, each with its live fetches in the period and the fetched_page visits that entered on it, the most visits first, then the most fetches.
  • median_lag_seconds: the median time from the fetch to the visit, for fetched_page visits.
  • revenue_left_out: money the chain can't tie to a visit, Stripe payments without the visitor's id and Odoo orders and won deals.
  • money_note, only when some amounts had no exchange rate for their day: how many, left out of the money.

When the period has no visit in the AI assistants channel, no live fetch and no one who said an assistant sent them, the block is a note instead of zeros. If the block can't be read in time, it's a note too, and the rest of the dashboard is complete.

Every ai_chain answer with levels carries this note, word for word:

A level says what happened in what order, not why. Most people who read an assistant's answer never click, so many fetches have no visit after them.

Who says an assistant sent them?

Many people read an assistant's answer, then come later by typing your address or searching your name. Those visits land in Direct or Organic search, never in a level. When your site asks "How did you hear about us?" and sends the answer as heard_from (see Custom events), the block counts those people in self_reported:

FieldWhat it is
peoplePeople with an answer in the period that names an AI assistant, whatever channel their visits came from.
conversionsTheir visits' conversions in the period, each counted once per visit.
revenueOrders in their visits in the period, those your server sent included, plus their Stripe payments when they sent no order in the period, in your project's currency.
also_in_levelsThose of them with a visit in the AI assistants channel in the period, so at one of the three levels too.

self_reported is never added to the levels. A person who is also at a level shows in both, and also_in_levels says how many did, so nothing is counted twice when you read them together.

A person counts once, however many times they answer, and when any of their answers names an assistant: "a friend", then "ChatGPT", counts. A person is someone who agreed to cookies or whom your site identified, by their own id or the user_id your server sends. A visitor who answers before agreeing to cookies has no id, so their answer counts once, in that visit, with that visit's conversions and orders. People you asked to forget are left out.

What does the chain leave out?

  • Visits that reach your site without the assistant's referrer or a UTM tag land in Direct, not the AI assistants channel, so they're not in the chain.
  • Gemini and Copilot visits are always ai_referred: their fetches can't be told apart from search crawling (see Why don't Gemini and Copilot show up?).
  • DuckAssistBot fetches show in routes but never give a visit a fetched_page or fetched_site level: nextanalytica doesn't tie them to an assistant's visits.
  • Stripe payments without the visitor's id and Odoo money are counted in revenue_left_out, not in a level.
  • The block covers every device, even when you ask the dashboard for one, and it has no comparison with the period before.

How do I check it works?

Ask your agent to check the setup:

  • "Check my nextanalytica setup." check_setup lists the senders that sent AI crawler hits in the last 7 days, or says none has.
  • "Which AI crawlers read my site this week?" get_dashboard has an ai_traffic block with crawlers (each bot with its purpose, its check result, its hits and the pages it read), crawled_routes (the pages bots read because a person asked an assistant about them, without unverified hits) and crawl_status (the hits by the class of status your site answered: 2xx, 3xx, 4xx, 5xx or unknown).

To try it, fetch a page with a bot's name as your user agent:

curl -A "ChatGPT-User/1.0" https://example.com/pricing

That hit comes from your own address, so it's stored as unverified: it shows the Worker works, and that nextanalytica doesn't trust a name alone.

Next steps

Related
  • What the tag collects: Page views, clicks, forms, scroll, errors and page speed, counted without code. What never leaves the page.
  • Add the tag: Put one script line in the head of every page. Where it goes in plain HTML, site builders and each framework.
  • WordPress and WooCommerce: The nextanalytica plugin for WordPress: connect in a few clicks, cookie banners through the WP Consent API and WooCommerce orders as purchases.
  • Cookieless counting and consent: The tag counts without cookies until a visitor agrees. How consent works, from your banner or your code.
  • Custom events: Send your own events and orders, such as sign-ups, demo requests and purchases, with one line of JavaScript each, so revenue ties to the visit.
  • Identify people: Name signed-in people with identify, so their visits on every device make one profile your agent can read. It works only after the visitor's consent.
Still have questions?
Was this page useful?