Track AI assistant traffic
Install the tracking file on a Next.js site, check that it works, and read which AI assistants fetch your pages.
AI assistants like ChatGPT, Claude, and Perplexity fetch web pages, but they don't run the site tag, so the tag never sees them. A small file on your site records each fetch in your PostHog project. Performance then shows the hits in its AI assistant traffic section.
A hit means an assistant fetched a page. It doesn't mean the assistant cited or recommended you.
Before you start
- The site runs Next.js 16 or later. Other site builders aren't supported yet.
- PostHog is connected in Connections > PostHog. Without it, the Website connection shows "Connect PostHog" instead of the file.
Install the file
- Open Connections > Website.
- Under AI assistant tracking, pick the website if you have more than one.
- Select Copy on the file.
- Save it as
proxy.tsat the root of the site's project and deploy. If the site already has aproxy.ts, the comment at the top of the file says how to merge the two.
The file already holds your PostHog project's public token, the same one the site tag uses. Copy a fresh file from Mark rather than editing it by hand.
Check the install
Select Check AI assistant tracking. Mark loads the site's home page as Mark-Probe, then waits up to 30 seconds for that visit to reach PostHog. Mark-Probe is Mark's own check. It never counts as an assistant.
| Result | What it means |
|---|---|
| Receiving | An AI assistant fetched a page in the last 7 days. |
| Installed | Mark's check reached PostHog. No assistant has visited in the last 7 days yet; on a small site that can take days. |
| Not installed | The site answered, but nothing reached PostHog. Deploy the file, or check again in a minute if you just did. |
| Blocked by the site's firewall | The site refused Mark's check, so Mark can't tell. Allow the Mark-Probe user agent in the site's firewall rules, then check again. |
| Site didn't answer or Site couldn't be reached | Mark couldn't load the home page. Check that the site is up. |
| Check failed | Mark couldn't read your PostHog project. Check again in a few minutes. |
The result shows for the website Mark last checked. Pick another website and select the button again to check that one.
Read AI assistant traffic
Open Performance and pick a range. The AI assistant traffic section shows:
- Hits: every assistant fetch in the range.
- Hits per assistant, split by kind:
- Crawler collects pages for training or an index (GPTBot, ClaudeBot, PerplexityBot).
- Search builds the assistant's own search results (OAI-SearchBot, Claude-SearchBot).
- User fetch loads a page because a person asked the assistant about it (ChatGPT-User, Claude-User, Perplexity-User).
- Top pages: the 10 pages fetched most.
- A "Data through" line with the newest hit.
With no hits in the range, the section says so and links to the Website connection.
Counts come from the user agent each assistant sends. Mark doesn't verify it, so anyone can send a request that claims to be GPTBot.
Site audit
Run an audit of a website or schedule one weekly, read its health score by category, and work through its issues by check or by page.
Check your keyword rankings
See where each tracked keyword ranks in Google for your site, run a check, set a weekly schedule, and read a keyword's position history.