BigQuery and GA4: how to redact parameters in code

Lace Chantelle Rogers
4 min readOct 3, 2022

As more and more people migrate from Universal Analytics to Google Analytics 4, we see more opportunities for people to use BigQuery to build truly enhanced reporting and optimised analytics.

However, it is also now more challenging to redact PII via Google Tag Manager which creates more reliance on robust code methodically to encrypt and prevent your websites and apps from sending PII to Google Analytics. This is a really positive move in the fact, since if the correct methodology is employed then you can be confident PII is not processed by Google.

So what happens when PII is sent to GA4? Firstly, you can process data deletion requests via the Google Analytics 4 interface as described in this link https://support.google.com/analytics/answer/9940393?hl=en.

But what happens to your BigQuery GA4 data when the worst happens and you detect PII? At present — nothing.

However, there are a number of choices, you could quite simply delete the tables with PII detected OR use a little BigQuery mastery to clean and redact the impacted data — allowing you to keep a clean and complete dataset.

The Code

This code will let you run each table update manually, with the condition you require to remove the PII. In this case, I have added two…

--

--

Lace Chantelle Rogers
Lace Chantelle Rogers

Written by Lace Chantelle Rogers

https://www.bigquery.co.uk/ leading data and analytics . GCP, BigQuery and GA4 expert specialising in data engineering, data science and Brighton cloud events.

Responses (2)