---
title: "Count visits that come from AI assistants · Agent Wranglers"
url: https://agentwranglers.se/playbook/seo/ai-search-answers/ai-referral-traffic
id: SEO-86
level: Recommended
updated: 2026-10-22
build: a2a6bdfed830
tokens: 926
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Count visits that come from AI assistants

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [AI search answers](https://agentwranglers.se/playbook/seo/ai-search-answers.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: SEO-86
- Level: Recommended
- Chapter: [AI search answers](https://agentwranglers.se/playbook/seo/ai-search-answers.md)
- Rule: Count visits from AI assistants as their own traffic source each month, by referrer host and by `utm_source`, per landing page. Report them next to search visits.
- Check: A unit test classifies sample visits with each listed referrer host as AI assistant traffic, and a visit from `www.google.com` as search. The monthly export has an AI assistant column for every landing page.
- How: People who click a link in an AI answer arrive with a referrer such as `chatgpt.com`, `perplexity.ai`, `gemini.google.com` or `copilot.microsoft.com`. Some links carry a `utm_source` that names the assistant instead. Keep the list of hosts in one file and add new assistants as they appear. Many visits lose their referrer, so read the count as a lower bound. Count without tracking people, as [Count visits without tracking people](https://agentwranglers.se/playbook/analytics/privacy-and-consent/analytics-consent.md) says. Put the numbers beside impressions, as [Measure impressions in AI answers](https://agentwranglers.se/playbook/seo/ai-search-answers/ai-impressions.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const AI_ASSISTANT_HOSTS = ['chatgpt.com', 'perplexity.ai', 'gemini.google.com', 'copilot.microsoft.com'];

export function trafficSource({ referrer, utmSource }) {
  const host = referrer ? new URL(referrer).hostname.replace(/^www\./, '') : '';
  if (AI_ASSISTANT_HOSTS.includes(host) || AI_ASSISTANT_HOSTS.includes(utmSource)) return 'ai-assistant';
  return host.startsWith('google.') || host === 'bing.com' ? 'search' : 'other';
}
```

### Python example

```python
from urllib.parse import urlparse

AI_ASSISTANT_HOSTS = {"chatgpt.com", "perplexity.ai", "gemini.google.com", "copilot.microsoft.com"}

def traffic_source(referrer: str, utm_source: str = "") -> str:
    host = (urlparse(referrer).hostname or "").removeprefix("www.")
    if host in AI_ASSISTANT_HOSTS or utm_source in AI_ASSISTANT_HOSTS:
        return "ai-assistant"
    return "search" if host.startswith("google.") or host == "bing.com" else "other"
```

## Sources

- [RFC 9110 (Referer)](https://www.rfc-editor.org/rfc/rfc9110#field.referer)

## Related rules

- ANA-7 [Track only after consent](https://agentwranglers.se/playbook/analytics/privacy-and-consent/analytics-consent.md) in Product analytics and experiments
- SEO-73 [Measure impressions in AI answers](https://agentwranglers.se/playbook/seo/ai-search-answers/ai-impressions.md) in SEO

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/seo/ai-search-answers/ai-referral-traffic">Agent Wranglers SEO playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Hiding instructions for AI models](https://agentwranglers.se/playbook/seo/ai-search-answers/prompt-injection-content.md)
- [AI search answers](https://agentwranglers.se/playbook/seo/ai-search-answers.md)
