Repository navigation
Description
What
Only persist an AI-traffic event when it is attributable to a specific AI platform, and make sure that attribution is filled in. Today the dashboard (/dashboard/traffic) shows an "Unknown" bucket; in the data that bucket is entirely rows with a null source_platform, and we'd rather not store those at all.
Findings (from ai_traffic_logs)
Captured source_platform values: chatgpt.com, search.chatgpt.com, perplexity.ai, gemini.google.com, claude.ai, copilot.microsoft.com, you.com, meta.ai, and (null).
- Every real host is already mapped to a display name in
PLATFORM_NAMES(traffic/_charts.tsx) — none of them renders as "Unknown". - The "Unknown" rows are the ones with
source_platform = null.
Root cause of the nulls: the snippet (server/src/public/t.js) derives the platform from the referrer hostname only (s: h). When a visit is detected via the utm_source/utm_medium fallback (no AI referrer), it sends an empty s → stored as null → "Unknown", even though the platform is known from the utm value.
Decision
Persist a visit when it is attributable to an AI platform by either signal:
- the referrer is a known AI domain (organic AI clicks — the primary value; many engines send only a referrer, e.g. Perplexity / Gemini / Copilot / Claude), or
utm_source/utm_mediumindicates an AI source (e.g. ChatGPT now appendsutm_source=chatgpt.comto outbound links).
If neither yields a platform, do not store the event (no more null/"Unknown" rows). Referrer-only and utm-only are both kept — we just always resolve a concrete platform, and drop the unattributable remainder.
Proposed
- Attribute platform from utm when there's no referrer. In
t.js, when detection fires viautm_source/utm_medium, set the platform from the matched utm value (chatgpt→chatgpt.com,perplexity→perplexity.ai,claude→claude.ai,gemini→gemini.google.com,copilot→copilot.microsoft.com). Prefer the referrer host when present. - Drop unattributable events. If no platform can be resolved (no AI referrer and no AI utm), don't send/store the event. Enforce in
t.js(already returns early when!f, so this is mostly guaranteed) and defensively in the/trackroute (server/src/routes/traffic.js) — reject/skip inserts with an emptysource_platform. - Sync the detection and display lists. Add
labs.googleand review the fullt.jsdomain list (chat.openai.com,phind.com,poe.com,bing.comvia/ck/a) so every detected source has aPLATFORM_NAMESlabel + color intraffic/_charts.tsx. - Optional — single source of truth. Derive the detection domains and the display names from one shared list so
t.jsand the dashboard can't drift again.
Known limitation (note, not in scope)
Google AI Overview clicks arrive with referrer = google.com and no utm (confirmed: Google does not tag AI Overview outbound clicks), so they're indistinguishable from regular Google search and won't be captured by either signal. Capturing them would need a separate heuristic (a distinguishing URL/referrer marker, if one exists) — out of scope here, worth a follow-up.
Acceptance
- A visit detected via
utm_source/utm_mediumrecords a concretesource_platform(not null) and shows under the right platform. - A visit with no AI referrer and no AI utm is not stored (no null
source_platformrows; the "Unknown" bucket disappears). - Referrer-based organic AI clicks (e.g. real
chatgpt.com/perplexity.aireferrer) are still captured and attributed. - Every host in the
t.jsdetection list has aPLATFORM_NAMESlabel + color;labs.googleincluded.
Notes
t.jsis cache-heavy (CDN + browser, hours); changes propagate only after a Cloudflare purge + cache expiry, so edits here won't take effect immediately for already-installed snippets.
Activity
[-]feat(traffic): attribute utm-detected visits to a platform + keep detection/display lists in sync[/-][+]feat(traffic): only persist platform-attributable AI visits (referrer or utm), drop unknowns[/+]feat(traffic): only persist platform-attributable AI visits (referrer…
feat(traffic): only persist platform-attributable AI visits (referrer…