A simple 2-step guide for removing PII from GA4 with GTM

  • Alex


    Head of Data Engineering

  • Magda Baciu

    Magda Baciu

    Founder & Head of Strategy

  1. What’s changed in GA4 compared to Universal Analytics?
  2. Creating the JS Variable
  3. GA4 Configuration


With the new Google Analytics (GA4) release, the common problem-fixes for GA Universal Analytics are no longer producing the expected results.

Such is the case for removing the PII (Personal Identifiable Information) from links via GTM. 

As you may know, the best way to stop your Analytics from collecting emails, names, addresses, or phone numbers, is through GTM.

However, when migrating your existing GTM solution for this issue to the new GA4, you’ll notice changes that render it obsolete. 

This is a well-known problem that can be fixed quickly by following a 2-step process that we share with you below. 

Step 1 – Create a new custom JS variable

To begin this setting, go to GTM and create a new Custom JavaScript variable.

Once you’ve created the variable, you will be able to insert the custom code. Get your ebook on How To Do Conversion Optimization Research Part 1

Your result should look exactly like this.

The code tells GTM not to send the information within specific parameters further to GA. 

As you can see, our example uses parameters such as ‘email,’ ‘name,’ ‘phone ‘address,’ or ‘city’. However, you can add or remove parameters at your own will.

So, if your website uses other parameters that contain PII, feel free to add them to the code – just make sure to follow our format.

Step 2 – GA4 Configuration

If you’re implementing GA4 via GTM, the first thing you have to configure is the new GTM tag named ‘Google Analytics: GA4 Configuration’.

Once you have that in place, all that’s left is to add a new row on ‘Fields to Set’ named ‘page_location.’ Make sure you include the newly created JS variable as ‘Value.’

Here is how this setting should look like:

Now click on Save and Preview this change, and you’re all done. From this point on, the page location will exclude PII parameters, and your new GA4 is ready to go. 

Easy enough? 

More tips, how-to guides, and articles are coming.  If you’d like to be the first who gets to read them, make sure to subscribe to our newsletter. We promise not to spam you or share your email with anyone else.

You can also show your support by hitting that share button and letting more people in on this know-how. 

Plus, if you’d like our experts to configure your Analytics or GTM or provide support in any marketing-related matter, fill in our contact form below, and we’ll rush to your assistance. 

See you next time! 

Our Free Measurement Plan Template


Learn From Us And Nail Advertising, Conversion Optimization, and Data Tracking

Free resources shared with our community only.

We're committed to your privacy. You may unsubscribe from these communications at any time. For more information, check out our privacy policy.

Marketing by

Leave a Reply

  • Ionut

    2 weeks ago


  • Ionut2

    2 weeks ago