Skip to main content
All CollectionsFAQ & TroubleshootingGeneral
Hiding Personally Identifiable Information (PII) in Google Analytics 3 And 4
Hiding Personally Identifiable Information (PII) in Google Analytics 3 And 4
Philip Schweizer avatar
Written by Philip Schweizer
Updated over a year ago

In order to offer our users a maximum of integrations with campaign, newsletter and mass emailing tools, we use the method to simply show a recipient's unique ID in the URL.

If you are a Google Analytics user, you're required to request Google Analytics to filter out this data of your leads to prevent Google Analytics from storing this (so called) Personally Identifiable Information (PII), and thus comply with their Terms of Services.

Please just follow these 2 simple steps for GA3:

(1) Go to Google Analytics "Admin" >> "All Website Data" >> "View Settings"

 

 

(2) In the field "Exclude URL Query Parameters", copy-paste the following text:

?id_op=

id_op

id_op=

?id_em=

id_em=

id_em

?id_mc=

?id_mc

id_mc

 

To exclude query parameters from Google Analytics 4, follow these steps:

  • Open your Google Tag Manager web container

  • Click on Variables, then create a new Custom JavaScript variable.

  • Once you’ve created the variable you’ll need to copy and paste the below JavaScript code.

function() {
var params = ['?id_op=', 'id_op', 'id_op=', '?id_em=', 'id_em=', 'id_em', '?id_mc=', '?id_mc', 'id_mc'];
var a = document.createElement('a');
var param,
qps,
iop,
ioe,
i;
a.href = document.URL;
if (a.search) {
qps = '&' + a.search.replace('?', '') + '&';
for (i = 0; i < params.length; i++) {
param = params[i];
iop = qps.indexOf('&' + param + '=');
if(iop > -1) {
ioe = qps.indexOf('&', iop + 1);
qps = qps.slice(0, iop) + qps.slice(ioe, qps.length);
}
}
a.search = qps.slice(1, qps.length - 1);
}
return a.href;
}
  • Your result should look exactly like this.

The code tells Google Tag Manager not to send the information within specific parameters further to Google Analytics.

As you can see, our example uses parameters such as "id_mc" "id_op". However, you can add or remove parameters at your own will.

  • Select your GA4 configuration tag, open fields to set, and set up as follow with your new variable before saving

  • Use GTM preview mode to verify query parameters are excluded as desired

  • Open the GA4 fired tag, select display variables as value, and verify the parameter doesn't show in the page location value

  • Publish your new version


That's it, you're all set!

Did this answer your question?