{"slug": "tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery", "title": "Tracking Traffic From ChatGPT, Perplexity and Gemini in GA4 and BigQuery", "summary": "A developer published a method for isolating traffic from AI assistants such as ChatGPT, Perplexity, Gemini, Copilot, Claude and DeepSeek in Google Analytics 4 and BigQuery. The approach adds a custom \"AI assistants\" channel group in GA4 that matches referrer hosts and utm_source values, and provides a BigQuery query that identifies the first page_view of each session attributed to an AI assistant. The writeup notes that AI Overviews and AI Mode clicks arrive as ordinary Google organic traffic and that mobile apps, privacy settings and copy-pasted URLs often strip the referrer, leaving much AI-influenced traffic unattributed.", "body_md": "AI visibility metrics tell you how often assistants mention and cite you. Sooner or later someone asks the follow-up: **does any of that turn into traffic?**\n\nPart of the answer is already in your analytics, mixed into \"Referral\" alongside every other website. This post separates it out:\n\nIt also covers the large share of AI-influenced traffic you **can't** see this way, because that limitation should shape how you report the numbers.\n\nWhen a user clicks a source link inside an AI answer, the visit arrives in one of three ways:\n\n| Signal | Example | Notes | \n|---|---|---|\n| Referrer header | `https://chatgpt.com/` ,`https://www.perplexity.ai/` | Most common for web clients. | \n| UTM parameter | `?utm_source=chatgpt.com` | ChatGPT adds this to many outbound links. | \n| Nothing | (direct) | Mobile apps, privacy settings and copy-pasted URLs often strip the referrer. | \n\nReferrer hosts to match (keep this list in one place, it changes):\n\n```\nchatgpt.com, chat.openai.com\nperplexity.ai, www.perplexity.ai\ngemini.google.com\ncopilot.microsoft.com\nclaude.ai\nchat.deepseek.com\n```\n\nGoogle's AI Overviews and AI Mode clicks generally come through as ordinary Google organic traffic, so they won't appear here.\n\nIn **Admin → Data display → Channel groups**, copy the default group and add a channel called **AI assistants** with this condition:\n\n```\n^(chatgpt\\.com|chat\\.openai\\.com|(www\\.)?perplexity\\.ai|gemini\\.google\\.com|copilot\\.microsoft\\.com|claude\\.ai|chat\\.deepseek\\.com)$\n```\n\nThen **drag the new channel above \"Referral\"**. Channels are evaluated in order, and the first match wins, so if Referral sits above it, AI traffic is still caught by Referral.\n\nBecause the rule matches *source*, it catches both referrer-based and `utm_source=chatgpt.com` visits. Custom channel groups also apply retroactively in GA4 reports, so you get history from day one.\n\nThe UI is fine for trends. For landing pages, joins and custom logic, use the BigQuery export. This query finds the first `page_view` of each session that came from an AI assistant, using either the referrer or the UTM source:\n\n```\nDECLARE ai_re STRING DEFAULT\n  r'(chatgpt\\.com|chat\\.openai\\.com|perplexity\\.ai|gemini\\.google\\.com|copilot\\.microsoft\\.com|claude\\.ai|chat\\.deepseek\\.com)';\n\nWITH pv AS (\n  SELECT\n    PARSE_DATE('%Y%m%d', event_date)                                   AS day,\n    user_pseudo_id,\n    (SELECT value.int_value    FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,\n    (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_location') AS page_location,\n    (SELECT value.string_value FROM UNNEST(event_params) WHERE key = 'page_referrer') AS page_referrer,\n    collected_traffic_source.manual_source                              AS utm_source,\n    event_timestamp\n  FROM `my-project.analytics_123456789.events_*`\n  WHERE _TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 28 DAY))\n                          AND FORMAT_DATE('%Y%m%d', CURRENT_DATE())\n    AND event_name = 'page_view'\n),\nlanding AS (\n  SELECT *,\n    ROW_NUMBER() OVER (PARTITION BY user_pseudo_id, session_id ORDER BY event_timestamp) AS rn\n  FROM pv\n)\nSELECT\n  day,\n  COALESCE(REGEXP_EXTRACT(page_referrer, ai_re), REGEXP_EXTRACT(utm_source, ai_re)) AS assistant,\n  REGEXP_REPLACE(REGEXP_EXTRACT(page_location, r'^https?://[^/]+([^?#]*)'), r'/$', '') AS landing_path,\n  COUNT(*) AS sessions\nFROM landing\nWHERE rn = 1\n  AND (REGEXP_CONTAINS(IFNULL(page_referrer, ''), ai_re)\n       OR REGEXP_CONTAINS(IFNULL(utm_source, ''), ai_re))\nGROUP BY day, assistant, landing_path\nORDER BY sessions DESC;\n```\n\nNotes:\n\n`collected_traffic_source` exists in exports from mid-2023 onward. For older data, rely on the referrer only.`REGEXP_EXTRACT` returns the matched host, so `www.perplexity.ai` and `perplexity.ai` both come out as `_TABLE_SUFFIX` keeps the scan, and the bill, to the date range you need.`events_*` matches `events_intraday_*` tables as well, so the most recent day can be double-counted. Use `events_2*` to match only the daily tables.\nIf you're collecting citations (see the earlier posts in this series), you have, per page, how often AI answers cited it. Now you have, per page, how many sessions AI assistants sent. Put them side by side:\n\n```\nWITH cited AS (\n  SELECT landing_path, SUM(citations) AS citations\n  FROM `my-project.ai_visibility.page_citations_28d`   -- your citation data, by path\n  GROUP BY landing_path\n),\nclicked AS (\n  SELECT landing_path, SUM(sessions) AS ai_sessions\n  FROM `my-project.ai_visibility.ai_sessions_28d`      -- the Step 2 result, saved\n  GROUP BY landing_path\n)\nSELECT\n  COALESCE(c.landing_path, k.landing_path) AS landing_path,\n  IFNULL(c.citations, 0)    AS citations,\n  IFNULL(k.ai_sessions, 0)  AS ai_sessions,\n  SAFE_DIVIDE(k.ai_sessions, c.citations) AS sessions_per_citation\nFROM cited c\nFULL OUTER JOIN clicked k USING (landing_path)\nORDER BY citations DESC;\n```\n\nThe four quadrants are the actionable part:\n\nBe upfront with stakeholders about three blind spots:\n\nThis is why referral traffic alone underrates AI search, and why it needs to sit next to visibility metrics rather than replace them.\n\nThe useful report puts visibility (mentions, citations, share of voice) and outcome (AI sessions, conversions) in front of the same people, at the same cadence.\n\n[Vista AI's Brand Visibility Dashboard](https://www.vistaai.io/features/brand-visibility-dashboard) covers the visibility side: visibility by engine and region, share of voice against competitors, sentiment, per-query rankings and 30/90/365-day trends, with weekly email reports. It also supports multiple brands with separate query sets, which helps agencies report per client. Pair it with the GA4 channel above and you have both halves: how often AI recommends you, and how often that recommendation becomes a visit.", "url": "https://wpnews.pro/news/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery", "canonical_source": "https://dev.to/furqank729/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery-4nd2", "published_at": "2026-10-16 06:00:00+00:00", "updated_at": "2026-10-16 06:04:56.879544+00:00", "lang": "en", "topics": ["ai-search", "ai-crawlers", "generative-engine-optimization"], "entities": ["Google Analytics 4", "BigQuery", "ChatGPT", "Perplexity", "Gemini", "Copilot", "Claude", "DeepSeek"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery", "markdown": "https://wpnews.pro/news/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery.md", "text": "https://wpnews.pro/news/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery.txt", "jsonld": "https://wpnews.pro/news/tracking-traffic-from-chatgpt-perplexity-and-gemini-in-ga4-and-bigquery.jsonld"}}