DEV Community

Lomen
Lomen

Posted on Originally published at lomenanalytics.com

How to tell if ChatGPT, Claude or Perplexity send visitors to your site (in any analytics tool)

Disclosure: we make Lomen, a website analytics tool, and this post is adapted from a longer guide on the Lomen blog. Nothing below needs Lomen. Everything works with the analytics you already use, or with none at all.

People ask AI assistants for recommendations and click the links in the answers. If your site gets cited, some of those clicks land on your pages. The question is whether you can see them.

Often you can, but they are easy to miss. This post covers where that traffic shows up, why some of it hides, and a small script you can drop in to label it yourself.

1. Two signals: the referrer and utm_source

An AI assistant visit can reach you with one or both of these:

  • The HTTP referrer. When someone clicks a link in a web-based assistant, the browser may send the assistant's domain as the referrer.
  • A utm_source query parameter. Some assistants add a UTM tag to outbound links, for example ?utm_source=chatgpt.com.

Neither signal is always present. Desktop and mobile apps, privacy settings and referrer policies can strip the referrer. Not every assistant adds UTM tags, and those that do can change their behaviour. Check both signals, not just one.

2. Domains to look for

These are the hostnames to watch for in your referrer reports. Domains change over time (copilot.microsoft.com, for example, now redirects to copilot.com), so treat this as a starting list and compare it with what actually shows up in your own data.

Assistant Referrer hostnames to check
ChatGPT chatgpt.com, chat.openai.com
Claude claude.ai
Perplexity perplexity.ai
Gemini gemini.google.com
Copilot copilot.com, copilot.microsoft.com
DeepSeek chat.deepseek.com
Grok grok.com
Meta AI meta.ai
Mistral chat.mistral.ai

3. Finding it in the tool you already have

Any tool with a referrer or source report. Open the sources or referrers list for a long date range and search for the hostnames above. Many tools let you filter with a regex. A starting pattern:

chatgpt\.com|chat\.openai\.com|claude\.ai|perplexity\.ai|gemini\.google\.com|copilot\.com|copilot\.microsoft\.com|deepseek\.com|grok\.com|meta\.ai|mistral\.ai
Enter fullscreen mode Exit fullscreen mode

Run the same filter against your UTM source dimension, not just the referrer. A visit tagged utm_source=chatgpt.com may be grouped under campaigns rather than referrals.

Server or CDN logs. If you keep access logs in the common "combined" format, the referrer is the fourth field when you split a line on double quotes. Count only that field:

awk -F'"' '{print $4}' access.log | grep -Eic 'chatgpt\.com|claude\.ai|perplexity\.ai|gemini\.google\.com|copilot\.com'
Enter fullscreen mode Exit fullscreen mode

Matching the whole line instead overcounts, because some AI crawlers put the assistant's domain in their user agent (PerplexityBot does). Those fetches are not visits. Adjust the file name, field and pattern for your setup.

4. Label it yourself with a small script

If your tool does not group these visits, you can classify them in the browser and pass the result along. This snippet checks the referrer first, then utm_source, and returns which assistant (if any) sent the visit:

const AI_SOURCES = [
  { name: 'ChatGPT',    hosts: ['chatgpt.com', 'chat.openai.com'],      utm: ['chatgpt'] },
  { name: 'Claude',     hosts: ['claude.ai'],                           utm: ['claude'] },
  { name: 'Perplexity', hosts: ['perplexity.ai'],                       utm: ['perplexity'] },
  { name: 'Gemini',     hosts: ['gemini.google.com'],                   utm: ['gemini'] },
  { name: 'Copilot',    hosts: ['copilot.com', 'copilot.microsoft.com'], utm: ['copilot'] },
  { name: 'DeepSeek',   hosts: ['chat.deepseek.com'],                   utm: ['deepseek'] },
  { name: 'Grok',       hosts: ['grok.com'],                            utm: ['grok'] },
  { name: 'Meta AI',    hosts: ['meta.ai'],                             utm: ['meta.ai', 'metaai'] },
  { name: 'Mistral',    hosts: ['chat.mistral.ai'],                     utm: ['mistral'] },
];

function detectAiSource() {
  const utm = (new URLSearchParams(location.search).get('utm_source') || '').toLowerCase();

  let host = '';
  try {
    host = new URL(document.referrer).hostname.replace(/^www\./, '');
  } catch (_) {
    // no referrer, or not a valid URL
  }

  // The referrer is the stronger signal, so check it for every assistant first.
  for (const s of AI_SOURCES) {
    if (host && s.hosts.some(h => host === h || host.endsWith('.' + h))) {
      return { assistant: s.name, via: 'referrer' };
    }
  }
  for (const s of AI_SOURCES) {
    if (utm && s.utm.some(u => utm.includes(u))) {
      return { assistant: s.name, via: 'utm_source' };
    }
  }
  return null;
}

const ai = detectAiSource();
if (ai) {
  // Send this to whatever you use: a custom event, a custom dimension,
  // your own endpoint, or just console.log while you test.
  console.log('AI assistant visit', ai);
}
Enter fullscreen mode Exit fullscreen mode

Notes on using it:

  • Run it once per page load, early. The utm_source is only in the URL on the landing page, so classify there and store the result for the session if you need it later.
  • Keep the matching loose on utm_source (substring) and strict on the hostname (exact or subdomain). Hostnames are predictable. UTM values are not.
  • Recording which signal matched (via) is useful. It tells you whether an assistant sends referrers, tags, or both.

5. Why some of it still looks like "direct"

You will not catch everything. Clicks from native apps often arrive with no referrer and no tag, and most tools then file them under direct traffic. There is no reliable way to recover those after the fact. If you see a rise in direct visits to deep pages (not your home page) at the same time assistants start citing you, that is a hint, not proof.

6. What to do with the numbers

  • Look at landing pages, not just totals. Which pages do assistant visitors land on? Those are the pages being cited.
  • Compare over weeks, not days. Volumes from a single assistant can be small, so day-to-day swings are mostly noise.
  • Keep assistant names out of your own UTM tags. A link you post yourself with utm_source=perplexity will look like a Perplexity referral. Tag your own links with the place you posted them.

If you have seen other assistant domains or utm_source values in your own data, the comments are a good place to share them.

Top comments (0)