cd /news/ai-search/how-many-visitors-do-chatgpt-and-per… · home › topics › ai-search › article
[ARTICLE · art-180285] src=dev.to ↗ pub= topic=ai-search verified=true sentiment=· neutral

How many visitors do ChatGPT and Perplexity actually send you? Count them from your access logs

A developer at Get AI Vizible published a Python script that counts visits sent to a site by AI assistants such as ChatGPT, Perplexity, Gemini, Copilot, Claude, DeepSeek and Grok, using only the standard library and Apache/Nginx combined access logs. The script matches the Referer header against known assistant hosts and also catches ChatGPT's utm_source=chatgpt.com tag, which it says is often the only trace left when mobile apps strip the referrer, then reports per-assistant totals and top landing pages. On a small test log it attributed 6 of 8 successful page views to an AI assistant.

key takeaway

Parse the Referer header against assistant hosts like chatgpt.com and perplexity.ai, and also check for utm_source=chatgpt.com, since mobile apps strip the referrer and the UTM tag is the only remaining trace.

by read3 min views18 publishedDec 2, 2026

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.

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.

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

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",
}
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:

www.perplexity.ai counts but a look-alike such as notchatgpt.com doesn't.2xx GET requests are counted, so 404s, redirects and form posts don't inflate the number. Treat the result as a floor, not the full picture:

Referrer-Policy settings drop the header. Apart from ChatGPT's UTM tag, those visits land in "direct".google.com, exactly like a normal search click. Search Console is the only place Google reports it. 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.

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.

── more in #ai-search 4 stories · sorted by recency
── more on @chatgpt 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-many-visitors-do…] indexed:0 read:3min 2026-12-02 · —