1. Data Processing and Aggregation
GA4 UI: The data shown in the GA4 interface often includes aggregated and sampled data to deliver quick insights. Metrics like user counts and session durations might be approximated using algorithms, which can lead to small discrepancies (1-4%) compared to raw data. In the consent mode era, the data can be completely different depending on the reporting identity.
BigQuery Export: This provides raw, unaggregated event-level data, allowing for more precise and detailed analysis. However, replicating the aggregated metrics shown in the UI might require more complex querying.
2. Metric Definitions and Calculations
User Metrics:
GA4 UI: It uses a default of 'Active Users' to quantify users rather than 'Total Users'. Depending on the reporting identity, this may also include modelled Users. Again, more on this is in the consent mode section.
BigQuery: Relies on user_pseudo_id and user_id (if set), giving a direct count of users based on events. Google Signals data and AI-driven predictions are not exported to BigQuery, which can lead to differences in user and session counts. Active users are also a possible metric you can extract from the BigQuery Export.
Session Metrics:
GA4 UI: Sessions are calculated using the session_start event and might be combined over multiple days if no session timeout occurs.
BigQuery: It requires explicit querying to combine user_pseudo_id with ga_session_id to calculate session metrics accurately. Sessions spanning multiple days need to be handled differently compared to the UI.
3. Data Retention and Historical Data
GA4 UI: Data retention policies may limit access to historical data (typically up to 14 months for non-standard reports)
BigQuery: It retains data indefinitely from the point of activation, allowing long-term historical analysis. Activating BigQuery export early is crucial as it does not backfill historical data.
Consent Mode isn't a simple feature; it dynamically adjusts how data is collected based on user consent, helping you maintain data integrity while respecting privacy preferences.
Accessing Traffic Source and Medium in GA4 BigQuery
In GA4's BigQuery export, traffic sources are represented primarily by the traffic_source table. Within this table, you can access vital fields such as:
traffic_source.source (the source of the traffic, like Google or Bing)
traffic_source.medium (the marketing medium, like "organic" or "CPC")
To map these fields into GA4's default channel groupings, you can query them directly from BigQuery using SQL. Here's a simplified query for obtaining the source and medium:
``sql SELECT traffic_source.source, traffic_source.medium, traffic_source.campaign FROM your_project.your_dataset.ga4_export_* WHERE _TABLE_SUFFIX BETWEEN '20240101' AND '20241231' ``
Recently, GA4 introduced a new dimension, session_traffic_source_last_click, which captures the last click attribution for a session. This data is available within nested fields in BigQuery and can provide more accurate attribution than the standard traffic_source fields. To retrieve this data, you can unnest the session_traffic_source_last_click field:
``sql SELECT event_date, session_traffic_source_last_click.manual_campaign.source AS session_source, session_traffic_source_last_click.manual_campaign.medium AS session_medium FROM your_project_id.your_dataset_id.ga4_table_name ``
Mapping to Default Channel Grouping
GA4's default channel groupings are rule-based classifications. These can be created in BigQuery by applying regex-based rules to the source and medium fields. For example:
``sql SELECT CASE WHEN traffic_source.source = 'google' AND traffic_source.medium = 'organic' THEN 'Organic Search' WHEN traffic_source.source = 'facebook' AND traffic_source.medium = 'social' THEN 'Social' ELSE 'Other' END AS default_channel_grouping FROM your_project.your_dataset.ga4_export_* ``
Differences from GA4 UI
In the GA4 Analytics UI, the traffic source and medium fields are readily available through predefined reports (like the Acquisition report). However, the UI's default channel grouping is predefined and cannot be customised directly. In BigQuery, you have much more flexibility, allowing for custom channel groupings and deeper attribution models. Additionally, the session_traffic_source_last_click field is exclusive to BigQuery and provides more accurate last-click attribution, which differs from the UI's built-in model.
Using BigQuery allows you to create custom rules and tweak the attribution models, offering more control than the GA4 interface.
By integrating the traffic_source fields and the session_traffic_source_last_click, you can gain a more comprehensive understanding of your traffic channels and their performance.


