Querying AI Referrals in GA4 BigQuery Without Double Counting A GA4 BigQuery analysis recommends reducing event rows to one row per session, keyed on user_pseudo_id, ga_session_id and stream_id, before counting AI referrals, because a single visit generates multiple event rows and counting rows as visits inflates totals or double-counts the same visit when AI referrals are added to a broader referral count. The approach classifies sessions using GA4's session-scoped session_traffic_source_last_click.manual_campaign.source and .medium fields, keeps an AI-referral flag as a subset or assigns each session to exactly one channel, and builds an allowlist of AI hostnames such as chatgpt.com, perplexity.ai, gemini.google.com and claude.ai from values actually present in the property rather than counting broad sources like bing.com. The query avoids CROSS JOIN UNNEST to prevent extra rows from event_params and uses page_referrer only as a diagnostic signal, since it does not guarantee a complete referral path. Reconciling Bing AI Performance Exports With Site Analytics Bing Webmaster Tools reports which pages Microsoft’s AI experiences cite in their answers. Your analytics and CRM systems record visits and business… Google Analytics 4 GA4 records website activity as events, such as page views and form submissions, and its BigQuery export stores those events in rows. One visit can produce many rows. Counting event rows as visits inflates the total. Adding AI referrals to a broader referral count can also count the same visit twice. The reliable approach is to reduce GA4 events to one row per session before counting or joining other data. A session is a group of events from one visit. Use GA4’s session-scoped source and medium fields to classify it, then keep an AI-referral flag as a subset or assign the session to exactly one channel. This identifies visits with observable AI-related source or referrer data; it does not measure every visit influenced by an AI answer. For reports about visits, start with session traffic source last click.manual campaign.source and .medium . GA4 uses these fields to attribute the visit's source where it came from and medium its traffic type to the session. The separate traffic source.source field shows the source that first brought the user to the site. It does not show which source brought in a later session. Google documents these distinctions in its BigQuery traffic attribution guidance https://developers.google.com/analytics/bigquery/traffic-attribution-data . Two other sets of fields can help you investigate a session's traffic source. collected traffic source.manual source and .manual medium contain source and medium values collected with an event. The event params array can contain ga session id , page location , and page referrer . Use page referrer to inspect the referring URL, especially on the session’s first page view. It is a diagnostic signal: it does not guarantee that GA4 recorded a complete referral path. The GA4 export schema https://support.google.com/analytics/answer/7029846 documents these fields and the repeated structure of event params . There is no guaranteed, complete list of hostnames for AI products. Build an allowlist from the source values in your GA4 property. Possible entries include chatgpt.com , perplexity.ai , gemini.google.com , and claude.ai , but check which values appear in your data and update the list to match. Do not count a broad source such as bing.com on its own, because it also represents ordinary search traffic. Examples from practitioners can help you start an investigation, but they are not an official or complete list of AI referrers. The query below reads event parameters without using CROSS JOIN UNNEST , which would create extra rows from the event parameters. It then groups events by user pseudo id , ga session id , and stream id . Google’s documented session-counting key combines user pseudo id and ga session id . Including stream id helps keep keys distinct when you combine data streams. See Google’s session-counting guidance https://developers.google.com/analytics/blog/2022/hll . Replace the project, dataset, date range, and hostname list. The example uses daily export tables and keeps the original source and medium fields for auditing. WITH event rows AS SELECT stream id, user pseudo id, event timestamp, event name, PARSE DATE '%Y%m%d', TABLE SUFFIX AS event date, SELECT ep.value.int value FROM UNNEST event params AS ep WHERE ep.key = 'ga session id' LIMIT 1 AS ga session id, SELECT ep.value.string value FROM UNNEST event params AS ep WHERE ep.key = 'page location' LIMIT 1 AS page location, SELECT ep.value.string value FROM UNNEST event params AS ep WHERE ep.key = 'page referrer' LIMIT 1 AS page referrer, session traffic source last click.manual campaign.source AS session source, session traffic source last click.manual campaign.medium AS session medium, collected traffic source.manual source AS collected source, collected traffic source.manual medium AS collected medium FROM