All articles
See AI and search crawlers
Your server tells Crustat when a known crawler, like ChatGPT, Claude or Googlebot, opens a page. See who came and what they read. Visits from people are never sent.
What it shows
AI assistants, search engines and other crawlers read your pages too. The Crawlers tab of your site shows which ones came and which pages they read, in four groups:
- AI answers: an AI assistant opened your page because someone asked it a question, like ChatGPT, Claude or Perplexity fetching a page to answer.
- Search indexing: search engines reading your pages to list them, like Googlebot, Bingbot and the search crawlers of AI tools.
- AI training: bots that collect pages to train AI models, like GPTBot, ClaudeBot and Common Crawl.
- SEO tools: crawlers from tools like Ahrefs and Semrush, which map sites for their users.
Crawler visits are kept apart from your visitor stats. They never change your visitors, page views or any other number on your dashboard.
Why the script can’t see them
Crustat’s script runs in the browser. Most crawlers don’t run scripts: they download the page and leave. So the script never sees them, and they’re also turned away on purpose, see how bots are kept out.
Your server does see them. So for crawlers, your server tells Crustat. It checks each request’s user agent (the short description every browser and bot sends) against a list of known crawler names. Only when it matches does it send a short note to Crustat. Requests from people stop right there and are never sent.
WordPress
Update the Crustat plugin. Crawler reporting is on by default, so there’s nothing else to do.
To turn it off, open the Settings drawer on the Crustat page in wp-admin and switch off Count crawler visits.
Behind a CDN or proxy, your server may see the proxy’s address instead of the crawler’s. Then Crustat can’t check the crawler, see what the labels mean. Developers can pass the real address with the crustat_crawler_ip filter:
add_filter( 'crustat_crawler_ip', function ( $ip ) {
return $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $ip;
} );
Only do this when a proxy you trust sets that header, because anyone can send it.
Next.js
Install or update @crustat/next, then call countCrawlers from your middleware. Use your site ID from Site settings → Install.
middleware.ts, next to your app or pages folder:
import type { NextFetchEvent, NextRequest } from 'next/server';
import { countCrawlers } from '@crustat/next/server';
export function middleware(request: NextRequest, event: NextFetchEvent) {
countCrawlers(request, event, { siteId: 'YOUR-SITE-ID' });
}
On Next.js 16, the same code goes in proxy.ts, with the function named proxy.
Already have middleware? Add the countCrawlers(...) line at the top of it. It returns nothing, doesn’t change the response, and never holds up the page. If your middleware has a matcher, crawlers are only reported on the paths it matches.
The crawler’s address is read from the x-forwarded-for header, then x-real-ip. Vercel and most hosts set these. Behind your own proxy, make sure it forwards the visitor’s address.
Astro
This works on server-rendered Astro sites (SSR, or hybrid with some pages rendered on demand). Install or update @crustat/astro, then add src/middleware.ts:
import { countCrawlers } from '@crustat/astro/middleware';
export const onRequest = countCrawlers({ siteId: 'YOUR-SITE-ID' });
Already have middleware? Combine them with sequence():
import { sequence } from 'astro:middleware';
import { countCrawlers } from '@crustat/astro/middleware';
import { auth } from './auth';
export const onRequest = sequence(countCrawlers({ siteId: 'YOUR-SITE-ID' }), auth);
Prerendered pages are skipped: they’re plain files, with no server to run middleware. For a fully static Astro site, use the Cloudflare example below, or the same idea on your host.
Static sites on Cloudflare
A static site has no server of its own, but Cloudflare can run a small function in front of it. On Cloudflare Pages, add functions/_middleware.ts to your project:
const SITE_ID = 'YOUR-SITE-ID';
// Known crawler names. Requests from anyone else are never sent.
const CRAWLERS = /ChatGPT-User|Perplexity-User|Claude-User|MistralAI-User|Googlebot|bingbot|OAI-SearchBot|PerplexityBot|Claude-SearchBot|DuckDuckBot|Applebot|YandexBot|Baiduspider|GPTBot|ClaudeBot|CCBot|Bytespider|meta-externalagent|Amazonbot|AhrefsBot|SemrushBot|MJ12bot|DotBot/i;
// Files that aren't pages. robots.txt, llms.txt, sitemaps and feeds are still sent.
const FILES = /\.(js|mjs|css|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|mp4|webm|mp3)$/i;
export const onRequest: PagesFunction = async (context) => {
const response = await context.next();
const { request } = context;
const ua = request.headers.get('user-agent') || '';
const url = new URL(request.url);
if (CRAWLERS.test(ua) && !FILES.test(url.pathname) && !url.pathname.startsWith('/_astro/')) {
const report = fetch('https://stats.crustat.com/crawl', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
site: SITE_ID,
url: url.href,
ua: ua.slice(0, 512),
ip: request.headers.get('cf-connecting-ip') || '',
status: response.status,
source: 'api',
v: 1,
}),
}).catch(() => {});
context.waitUntil(report); // Sent after the page, never in its way.
}
return response;
};
With middleware in place, every request to your site runs through it, which counts toward your Cloudflare plan’s request limits.
On Cloudflare Workers with static assets, the same check goes in your Worker’s fetch handler: get the page with env.ASSETS.fetch(request), report with ctx.waitUntil(...), and set run_worker_first = true under [assets] in your Wrangler file so the Worker sees every request.
Any other server
Send one request for each crawler visit, after checking the user agent yourself:
curl -X POST https://stats.crustat.com/crawl \
-H 'content-type: application/json' \
-d '{"site":"YOUR-SITE-ID","url":"https://example.com/pricing","ua":"Mozilla/5.0 (compatible; GPTBot/1.2; +https://openai.com/gptbot)","ip":"203.0.113.7","status":200,"source":"api","v":1}'
- site: your site ID.
- url: the full address of the page the crawler asked for.
- ua: the crawler’s user agent, as it sent it.
- ip: the crawler’s IP address, so Crustat can check it.
- status: the response code your server sent, like 200 or 404. Leave it out if you don’t know it.
- source:
api. v:1.
The body can be up to 2 KB. Crustat always answers with an empty 204, so there’s nothing to read back. Don’t wait for it before sending your page, and ignore any error.
In plain PHP, for example, at the end of your front controller:
<?php
register_shutdown_function(function () {
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
// Known crawler names. Requests from anyone else are never sent.
if (!preg_match('/ChatGPT-User|Perplexity-User|Claude-User|MistralAI-User|Googlebot|bingbot|OAI-SearchBot|PerplexityBot|Claude-SearchBot|DuckDuckBot|Applebot|YandexBot|Baiduspider|GPTBot|ClaudeBot|CCBot|Bytespider|meta-externalagent|Amazonbot|AhrefsBot|SemrushBot|MJ12bot|DotBot/i', $ua)) {
return;
}
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request(); // The page is already sent; report after it.
}
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
$ch = curl_init('https://stats.crustat.com/crawl');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['content-type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'site' => 'YOUR-SITE-ID',
'url' => ($https ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'ua' => substr($ua, 0, 512),
'ip' => $_SERVER['REMOTE_ADDR'] ?? '',
'status' => http_response_code() ?: null,
'source' => 'api',
'v' => 1,
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT_MS => 1000,
]);
curl_exec($ch); // Errors are ignored on purpose.
curl_close($ch);
});
Send pages, not files: skip images, scripts, styles and fonts. Do send robots.txt, llms.txt, sitemaps and feeds, which crawlers read on purpose. If a name you send isn’t one Crustat knows, it’s simply dropped.
What the labels mean
Anyone can put “Googlebot” in a user agent. So for each visit, Crustat checks the IP address against the addresses the crawler’s company publishes, where it publishes them:
- Verified: the address belongs to the company that runs the crawler. It’s the real one.
- Not verified: the company publishes its addresses, and this one isn’t among them. Most likely someone else using the crawler’s name. It’s also what you see when a proxy or CDN sends its own address instead of the crawler’s.
- Can’t be checked: the company doesn’t publish its addresses, so there’s nothing to check against.
What is and isn’t sent
- Never people. Your server checks the user agent first. If it isn’t a known crawler, nothing is sent.
- For a crawler: the page address, the crawler’s user agent, its IP address and the response code.
- The IP address is only used to check the crawler. Crustat doesn’t keep it.
- No cookies, and nothing is added to your pages.
What to keep in mind
- Only requests that reach your server are seen. Pages served from a cache or CDN without reaching your server aren’t, so the numbers can be lower than your host’s logs.
- Only named crawlers are shown. Bots that pretend to be a normal browser don’t say who they are, so they don’t appear here. Some of them end up in the set-aside visits instead, see how bots are kept out.
Price
Crawler visits are free and never use your plan’s page views & events. Each workspace gets up to 100,000 crawler visits a month. Past that, only crawler counting pauses until the 1st of the next month. Your visitor stats carry on as usual. See plans, trial and billing.
Turn it off
Open your site’s Site settings → Install in Crustat and switch off Count crawler visits. Crustat then stops counting them for that site. On WordPress you can also switch off Count crawler visits in the plugin’s Settings, so nothing is sent at all.
Still stuck? Write to hello@crustat.com.