Skip to main content

GA4 | tips & tricks

Navigating consent mode in the GA4 BigQuery export

This article explores how to effectively query the GA4 BigQuery export data in two specific consent mode implementation scenarios: basic and advanced consent mode.

Information on the consent is stored in the record privacy_info. It contains three fields:

  • privacy_info.analytics_storage
  • privacy_info.ads_storage
  • privacy_info.uses_transient_token

We will ignore the last field, as Google doesn't provide any definition.

Both analytics_storage and ads_storage can contain these values:

  • Yes (= consent granted)
  • No (= consent denied)
  • null (= unknown / no consent mode implemented)

Basic or advanced?

If you are not sure what scenario fits your needs, you can run a query like the one below on your GA4 export data. Make sure to pick a recent event table.

  count(*) as events_total,
  count(distinct user_pseudo_id) as users,
  count(distinct concat(user_pseudo_id,(select value.int_value from unnest(event_params) where key = 'ga_session_id'))) as sessions
group by

If consent mode is not implemented, your results will look like this. Just a bunch of null values in the fields analytics_storage and ads_storage.

Below an example of a basic consent mode implementation. The field analytics_storage only contains value Yes. The ads_storage values can be both Yes or No.

Basic consent mode simplifies the user consent process but imposes limitations on the data collected. In this scenario, Google tags are entirely blocked until the user grants explicit consent through a consent banner. If consent is denied, no data is collected and there is no data available in the BigQuery export.

Advanced Consent Mode offers more granular control over how data is handled based on the user's consent state, allowing for more sophisticated data collection strategies, even when consent is partially or fully denied.

Below an example of an advanced consent mode implementation, varying from Yes, Yes to No, No and even some null values (which we will ignore here).

Cookieless pings

In scenarios using advanced consent mode, GA4 collects hits even when consent is denied, stripping off parameters like client id and session id. We call those 'cookieless pings'. All events, users and sessions for the rows where analytics_storage is No, are called cookieless pings. These events don't contain a user_pseudo_id and ga_session_id, hence the 0 when trying to count the distinct amounts.

However, if consent is later granted on the same page, these hits can undergo a modeling process, enriching reports once modeled without needing to resend hits. This reprocessing is evident in BigQuery exports, as Simo Ahava showed, where previously denied hits appear as if consent was granted.

The impact

As said, the impact of GA4 consent mode on the BigQuery export can be particularly complex due to those cookieless pings, which lack user_pseudo_id and ga_session_id, complicating data analysis and user/session tracking. But not only is it hard to count users or sessions, also some user/session scoped events will be less reliable: every page view from a non-consented user in an advanced consent mode implementation will trigger a session_start and potentially even a first_visit event.

To navigate this complexity, it could be a strategy to shift your focus from user and session metrics to event metrics and trends. For instance, instead of counting unique users or sessions, you can analyze the frequency and patterns of specific events like page views or purchases.

Another approach is filtering out non-consenting users from your reports, by adding something like this to your query:

  privacy_info.analytics_storage = 'Yes'

While it provides a cleaner data set, this method introduces its own set of biases. Consent rates often vary among different user demographics, meaning the data you analyze might not be representative of your entire audience. More on this in this excellent article by Guillaume Wagner.

Navigating the complexities of GA4 consent mode in BigQuery is challenging, and with the future of GA4 export data still uncertain, it's all about staying flexible and keeping up with the latest changes.

Now it's your turn!

I hope you've enjoyed this article and feel a bit more confident to utilise your own Google Analytics data in BigQuery. Drop a line in the comments if you have any questions, feedback or suggestions related to this article.