
Measuring AI agents on your website
Measuring AI agents on your website: a small-site analytics setup that separates bots, assistants and people
A small-site how-to: write a 20-line script that sorts web server log lines into AI training crawlers, AI search crawlers, assistants fetching a page for a user, search engines and likely people, test it on a log you generate yourself, and learn where it fails:
Your analytics dashboard counts people. Your server counts everything that asks for a page, and since AI products started fetching pages on behalf of users, that second number has become worth reading. This how-to builds the smallest useful version: a short Python script that reads an ordinary access log and sorts each request into AI training crawler, AI search crawler, assistant fetching for a user, search engine, other bot or likely person. I tested it on a log I generated myself, from the user-agent strings the vendors publish, and it got something wrong on the first run. I also checked the live robots.txt on corecodify.com, fetched the home page with eight bot identities, and pulled our own Search Console numbers. One limit up front: corecodify.com is a static site on shared hosting, and I cannot read its raw server logs, so I make no claim about how much AI traffic it receives.
The three kinds of visitor, and what each one sends
A request reveals very little: an IP address, a path and a user-agent header. The user-agent is a string the client chooses, so it is a label and not proof, but the major AI vendors publish the labels they use, which is enough for a first pass. They fall into three groups with different rules. Training crawlers such as GPTBot and ClaudeBot collect content for model development and obey robots.txt. Search crawlers such as OAI-SearchBot and PerplexityBot build the index behind an AI search feature. Then there are fetchers that act when a person asks a question, such as ChatGPT-User, Claude-User and Perplexity-User. Those are the closest thing to a visit from a person, and vendors treat them differently from crawlers.
The difference matters because your robots.txt does not control the third group the same way. OpenAI's documentation says of ChatGPT-User: "Because these actions are initiated by a user, robots.txt rules may not apply." Perplexity says of Perplexity-User: "Since a user requested the fetch, this fetcher generally ignores robots.txt rules." One more wrinkle: Google-Extended is not a visitor at all. Google's documentation states that it "doesn't have a separate HTTP request user agent string", so it is a robots.txt token only and you will never see it in a log.
Step 1: write down the labels you are looking for
I copied the example user-agent strings from each vendor's own page on 4 December 2026 and kept them in a table. Anthropic's support page names ClaudeBot, Claude-User and Claude-SearchBot and what each is for, but does not print a full user-agent string, so for those I built a plausible string around the published name. That is a weakness in my test, so the rule matches on the name only.
| Label in the log | Operator | What it is | Does robots.txt apply? |
|---|---|---|---|
| GPTBot | OpenAI | Crawls content that may train models | Yes, vendor says disallowing it opts out |
| OAI-SearchBot | OpenAI | Surfaces sites in ChatGPT search | Yes |
| ChatGPT-User | OpenAI | Fetch triggered by a user action | May not apply |
| ClaudeBot | Anthropic | Training crawler | Yes |
| Claude-SearchBot | Anthropic | Improves search result quality | Yes |
| Claude-User | Anthropic | Fetch when a user asks Claude | Vendor says it can be controlled in robots.txt |
| PerplexityBot | Perplexity | Surfaces sites in Perplexity search | Yes |
| Perplexity-User | Perplexity | Fetch triggered by a user question | Generally ignores it |
| Googlebot | Search crawler | Yes | |
| Google-Read-Aloud | User-triggered text-to-speech fetch | User-triggered fetcher | |
| Google-Extended | robots.txt token only, no user-agent string | Yes, token only |
Step 2: make a log you can trust, because you made it
I had no access log for corecodify.com, and I did not want to test on invented numbers. So I started a ten-line Python web server on the box that writes each request in the standard combined log format, then sent it real requests: ten user-agent strings with three paths each (the home page, a pricing page and robots.txt), and six page loads from Chrome, three in a headed window and three headless. That made a log of 36 lines. The counts are test traffic that I chose, not a sample of the web, so the percentages below describe my test and nothing else.
Step 3: the classifier, and the line it got wrong
The whole classifier is a list of rules checked in order, where the first match wins. Order matters because OAI-SearchBot's real string also contains Chrome and Safari, and a Googlebot string contains the word Mozilla. Put the specific names first and the generic ones last.
This is the version that produced the results below (anything that starts with Mozilla/ and matches no rule is called a likely person):

import re, sys, json, collections
# Order matters: the first matching rule wins.
RULES = [
("ai-training", r"GPTBot|ClaudeBot|CCBot|Bytespider"),
("ai-search", r"OAI-SearchBot|Claude-SearchBot|PerplexityBot"),
("ai-assistant", r"ChatGPT-User|Claude-User|Perplexity-User|Google-Agent|Google-NotebookLM|Google-Read-Aloud"),
("search-engine", r"Googlebot|bingbot|Mediapartners-Google"),
("other-bot", r"bot\b|crawler|spider|curl/|python-requests|Go-http-client|HeadlessChrome"),
]
LINE = re.compile(r'^(\S+) \S+ \S+ \[[^\]]+\] "(\S+) (\S+) [^"]*" (\d{3}) \S+ "[^"]*" "([^"]*)"')
def classify(ua):
for name, pat in RULES:
if re.search(pat, ua, re.I if name=="other-bot" else 0): return name
return "likely-person" if ua.startswith("Mozilla/") else "unknown"On the first run, six lines came back as likely-person. I knew only three should: the headed Chrome visits. The other three were Google-Read-Aloud, a user-triggered fetcher whose string begins with Mozilla/5.0 and which my rules had not listed, so it fell through to the browser rule. Adding its name to the assistant rule fixed it, and the second run matched what I had sent: 12 assistant-type fetches, 6 training, 6 search, 6 other bots, 3 search engine and 3 likely people. A script that quietly files an unknown fetcher under people is the worst failure here, so read a sample of the unmatched lines regularly.
Step 4: know what the script cannot tell you
Two blind spots showed up in my own test, and neither can be fixed with a longer rule list.
First, the headless Chrome visits were easy to spot because the browser puts HeadlessChrome in its string. The headed Chrome visits were not: their user-agent is identical in form to a person's, so they landed under likely-person, which is what the script is supposed to say about them. An agent that drives an ordinary browser window looks like a visitor in a log, and a user-agent rule cannot separate them.
Second, the label is self-declared. All 30 requests that carried a bot or tool user-agent came from 127.0.0.1, my own machine. I downloaded the IP lists OpenAI publishes (openai.com/gptbot.json had 18 prefixes, searchbot.json 39 and chatgpt-user.json 366 on 4 December) and checked my address against them: none matched, which is exactly what you want to see for a fake GPTBot. Google publishes instructions for verifying its crawlers, and Perplexity publishes its own IP files (both linked below). For anything you plan to block or bill against, verify the address as well as the label.
- Count a line as confirmed only if the label and a published IP range agree.
- Keep likely-person as a separate, unverified bucket, and treat it as an upper bound, not a head count.
- Log the full user-agent for unmatched lines so that new fetchers show up as a pattern.
Step 5: check what your robots.txt actually says to each bot
Logs show who came. robots.txt decides who is invited, so I read ours in a real Chrome window and tested it. The live file has a general group that allows everything except /admin/, /api/, /manage and /catalog-api/, and a second group naming GPTBot, OAI-SearchBot, PerplexityBot, ClaudeBot and Google-Extended with the same rules, so those crawlers are named instead of left to the general group.
Then I fetched the home page once for each of eight identities: GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-User, PerplexityBot, Perplexity-User and Googlebot. Every one got HTTP 200 and exactly 36,976 bytes, the same as any other client. In other words, nothing in the hosting or CDN layer treats them differently from a browser, and the only gate is the robots.txt file itself. (Google-Extended is a ninth name in my robots check, but it has no user-agent string to send, so it was only tested against the file.)

The test turned up a trap. I asked Python's built-in robots.txt parser whether GPTBot, ClaudeBot, PerplexityBot, Googlebot and an unknown bot may fetch /admin/. It said yes for all five. A parser that follows the standard says no. RFC 9309 says: "The most specific match found MUST be used. The most specific match is the match that has the most octets." Our file lists Allow: / before Disallow: /admin/, and Python's parser, in my test, took the first rule that matched, while the longest match is Disallow: /admin/. The file's intent is clear, but a home-made check with the standard library would have told me the private paths were open. I wrote a small longest-match function for the check instead; I did not test how each crawler parses the file.
If you test your robots.txt before a deploy, test it with a parser that implements RFC 9309, and keep the order of rules readable for humans anyway.
Step 6: add the people side, and be honest about its size
Server logs cover machines and people together. For the search side of the picture I queried our Search Console property for corecodify.com for the 28 days from 4 November to 1 December 2026: 12 clicks on 4,520 impressions, an average position of 23.9, with 11 of the clicks on desktop. Search Console reports search clicks and impressions. It does not list crawler visits and it does not show assistant fetches, so it cannot answer the bot question. Its job in this setup is to give a rough sense of scale for real search visitors, and for a young site that scale is small.
The discipline is to keep the buckets separate. A log full of requests is not a crowd of readers, and a report that blends crawlers with people would flatter the site.

A last practical note. If you want a full pass over crawl access, robots.txt policy and how to confirm a bot is genuine across more crawlers than I covered here, the AI Search Visibility Audit Kit lists 14 AI crawler user-agents with a sample robots.txt policy.
What I did not do
I did not read corecodify.com's own access logs, so there are no figures here for how often AI crawlers visit it. Bingbot, Applebot, Meta's crawlers and others are missing from my table, and Anthropic's strings in the test log were built from its documented names. A 36-line log shows the rules behave on known input, not how they cope with a busy site. With real logs, run the script over a week and read every line it files under likely-person or other-bot before trusting a total.
FAQ
Can I tell an AI agent from a person using the user-agent alone?
Only some of the time. Declared crawlers and user-triggered fetchers name themselves, and the vendors publish those names. An agent that drives a normal Chrome window sends an ordinary browser string, so it counts as a person. In my test the headed Chrome visits were indistinguishable by user-agent, while headless Chrome announced itself as HeadlessChrome.
Does blocking GPTBot or ClaudeBot stop assistants from reading my pages?
No, those names cover training crawlers. OpenAI says GPTBot is for crawling content that may be used in training, and ChatGPT-User is for user actions, where robots.txt rules may not apply. Anthropic lists ClaudeBot, Claude-User and Claude-SearchBot as separate robots with separate effects when disabled. Decide each one on its own.
Why is Google-Extended missing from my logs?
It never appears there. Google's documentation says Google-Extended has no separate HTTP request user agent string and works only as a robots.txt token. Crawling is done with Google's existing user agents.
Sources
- OpenAI: Overview of OpenAI Crawlers (GPTBot, OAI-SearchBot, ChatGPT-User, example user-agent strings, published IP files)
- OpenAI published IP ranges: GPTBot
- OpenAI published IP ranges: OAI-SearchBot
- OpenAI published IP ranges: ChatGPT-User
- Anthropic: Does Anthropic crawl data from the web, and how can site owners block the crawler?
- Perplexity: Perplexity Crawlers (PerplexityBot and Perplexity-User)
- Google Search Central: Google's common crawlers (Googlebot, Google-Extended)
- Google Search Central: Google's user-triggered fetchers (Google-Read-Aloud, Google-Agent)
- Google Search Central: Verifying Googlebot and other Google crawlers
- Google Search Console API: Search Analytics query
- RFC 9309: Robots Exclusion Protocol (the longest-match rule, quoted)
- Python documentation: urllib.robotparser
- CoreCodify robots.txt (read live on 4 December 2026)





