Skip to content

feat(traffic): only persist platform-attributable AI visits (referrer or utm), drop unknowns #288

Closed

Description

@gkhngyk

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_medium indicates an AI source (e.g. ChatGPT now appends utm_source=chatgpt.com to 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

  1. Attribute platform from utm when there's no referrer. In t.js, when detection fires via utm_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.
  2. 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 /track route (server/src/routes/traffic.js) — reject/skip inserts with an empty source_platform.
  3. Sync the detection and display lists. Add labs.google and review the full t.js domain list (chat.openai.com, phind.com, poe.com, bing.com via /ck/a) so every detected source has a PLATFORM_NAMES label + color in traffic/_charts.tsx.
  4. Optional — single source of truth. Derive the detection domains and the display names from one shared list so t.js and 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_medium records a concrete source_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_platform rows; the "Unknown" bucket disappears).
  • Referrer-based organic AI clicks (e.g. real chatgpt.com / perplexity.ai referrer) are still captured and attributed.
  • Every host in the t.js detection list has a PLATFORM_NAMES label + color; labs.google included.

Notes

  • t.js is 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

  1. added
    enhancement
    on Jun 22, 2026
  2. changed the title [-]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[/+] on Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions