Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Tracking ChatGPT, Perplexity and Claude Referrals Properly: GA4 Regex, Server Logs and the 'Dark AI' Problem

Description and use

Implementing a classifier, GA4 custom channel group, server‑side middleware, and SQL reporting fully tracks AI assistant traffic, including dark traffic.

Problem

Accurately attributing traffic from AI assistants is difficult because default analytics miss several traffic shapes.

Outcome

All AI traffic shapes are now tracked, enabling accurate attribution and estimation of dark AI traffic.

Workflow

  • Define AI source rules in a shared module (AI_SOURCES).
  • Create a classifyAI function that checks referrer host and UTM source.
  • Add GA4 custom channel group regex to group AI traffic.
  • Implement Express/Next.js middleware to log AI visits server‑side.
  • Write SQL queries to report AI traffic and estimate dark AI portion.

Evidence

A classifier that recognises AI referrals from the referrer and UTM tags

Source

GA4 custom channel group regex

Source

Express/Next.js middleware to log AI visits server-side

Source

SQL to report on them, plus a way to estimate the part you can't see

Source

  • Record date: 2026-10-23T07:11:19.917Z