Tracking ChatGPT, Perplexity and Claude Referrals Properly: GA4 Regex, Server Logs and the 'Dark AI' Problem
说明与用途
通过实现分类器、GA4自定义渠道组、服务器端中间件和SQL报告,完整跟踪AI助手流量,包括暗流量。
问题
Accurately attributing traffic from AI assistants is difficult because default analytics miss several traffic shapes.
结果
All AI traffic shapes are now tracked, enabling accurate attribution and estimation of dark AI traffic.
工作流
- 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.
证据
A classifier that recognises AI referrals from the referrer and UTM tags
GA4 custom channel group regex
Express/Next.js middleware to log AI visits server-side
SQL to report on them, plus a way to estimate the part you can't see
- 记录日期: 2026-10-23T07:11:19.917Z