Disclosure: I work on Get AI Vizible, which tracks how AI assistants mention brands. Nothing below needs it: just a log file and the Python standard library. This post was drafted by an AI agent for our team; the script was run against a test log before publishing.
Everyone is talking about "AI search traffic", but most analytics dashboards lump it into "referral" or "direct". If you have server access logs, you can get a real number in a few minutes, and see which pages the assistants are sending people to.
What an AI referral looks like in a log
When someone clicks a link inside an AI assistant's answer, the visit usually carries the assistant's domain in the Referer header:
| Assistant | Referrer host |
|---|---|
| ChatGPT | chatgpt.com (older links: chat.openai.com) |
| Perplexity | perplexity.ai / www.perplexity.ai |
| Gemini | gemini.google.com |
| Microsoft Copilot | copilot.microsoft.com |
| Claude | claude.ai |
| DeepSeek | chat.deepseek.com |
| Grok | grok.com |
ChatGPT also appends utm_source=chatgpt.com to the links it shows. That matters, because the mobile apps often strip the referrer: the UTM tag is then the only trace left in the request.
The script
It reads the standard Apache/Nginx "combined" format, keeps successful GET requests, and counts the ones that came from an assistant, with the top landing pages for each:
#!/usr/bin/env python3 """Count visits that AI assistants send to your site, from an access log. Usage: python ai_referrals.py access.log [access.log.1 ...] Reads Apache/Nginx "combined" format. Standard library only. """ import re import sys from collections import Counter, defaultdict from urllib.parse import urlsplit, parse_qs # Referrer host -> assistant. Subdomains match too (www.perplexity.ai). AI_HOSTS = { "chatgpt.com": "ChatGPT", "chat.openai.com": "ChatGPT", "perplexity.ai": "Perplexity", "gemini.google.com": "Gemini", "copilot.microsoft.com": "Copilot", "claude.ai": "Claude", "chat.deepseek.com": "DeepSeek", "grok.com": "Grok", } # ChatGPT adds utm_source=chatgpt.com to links it shows; this catches visits # whose referrer was stripped (common from the mobile apps). AI_UTM = {"chatgpt.com": "ChatGPT"} LINE = re.compile( r'(?P<ip>\S+) \S+ \S+ \[(?P<time>[^\]]+)\] "(?P<method>\S+) (?P<path>\S+) [^"]*" ' r'(?P<status>\d{3}) \S+ "(?P<ref>[^"]*)" "(?P<ua>[^"]*)"' ) def assistant_for(ref, path): host = (urlsplit(ref).hostname or "") if ref not in ("", "-") else "" for known, name in AI_HOSTS.items(): if host == known or host.endswith("." + known): return name source = parse_qs(urlsplit(path).query).get("utm_source", [""])[0].lower() return AI_UTM.get(source) def main(files): by_ai, pages = Counter(), defaultdict(Counter) total = 0 for name in files: with open(name, encoding="utf-8", errors="replace") as fh: for line in fh: m = LINE.match(line) if not m or m["method"] != "GET" or not m["status"].startswith("2"): continue total += 1 ai = assistant_for(m["ref"], m["path"]) if ai: by_ai[ai] += 1 pages[ai][urlsplit(m["path"]).path] += 1 found = sum(by_ai.values()) print(f"{found} of {total} successful page views came from an AI assistant") for ai, n in by_ai.most_common(): top = ", ".join(f"{p} ({c})" for p, c in pages[ai].most_common(3)) print(f" {ai:<11}{n:>6} top pages: {top}") if __name__ == "__main__": if len(sys.argv) < 2: sys.exit(__doc__) main(sys.argv[1:]) Run it on today's log, or on a week of rotated logs at once:
python ai_referrals.py /var/log/nginx/access.log /var/log/nginx/access.log.1 On a small test log it prints:
6 of 8 successful page views came from an AI assistant ChatGPT 3 top pages: /pricing (2), /blog/llms-txt (1) Perplexity 1 top pages: /blog/llms-txt (1) Gemini 1 top pages: / (1) Claude 1 top pages: /pricing (1) A few details worth noting:
- Hosts are matched exactly or as subdomains, so
www.perplexity.aicounts but a look-alike such asnotchatgpt.comdoesn't. - Only
2xxGETrequests are counted, so 404s, redirects and form posts don't inflate the number. - Bot traffic isn't an issue here: crawlers like GPTBot don't send an AI referrer. (If you want to verify crawler hits too, see my earlier post on spotting fake AI crawlers.)
What this number can't tell you
Treat the result as a floor, not the full picture:
- Missing referrers. Apps, privacy browsers and strict
Referrer-Policysettings drop the header. Apart from ChatGPT's UTM tag, those visits land in "direct". - Google's AI features are invisible here. A click from an AI Overview or AI Mode arrives as
google.com, exactly like a normal search click. Search Console is the only place Google reports it. - Mentions without clicks. Most AI answers name a brand without the user clicking anything. Logs only see the clicks, so being recommended and being visited are two different measurements.
Even with those gaps, the landing-page list is useful. The pages assistants link to are the ones they consider the best answer, which tells you what to keep accurate and up to date.
Quick wins once you have the numbers
- Check that the top landing pages load fast and answer the question in the first paragraph. That's what the user clicked for.
- Look for pages assistants send people to that have no clear next step, and add one.
- Compare month over month. A sudden drop for one assistant usually means a page moved, broke or got blocked in
robots.txt.
If you run this on your own logs, I'm curious which assistant comes out on top for you. Let me know in the comments.