analytics ninja
analytics ninja

Reputation: 83

Partial IP Anonymization using DTM

Is there a way to anonymize IP based on the URL address. The site runs across many countries, and we need to anonymize the IPs for the traffic coming from a specific country only. The subdomains are different based on the countries.

My analytics setup utilizes DTM (Dynamic Tag manager) and is configured to send data to GA (Google Analytics)

Upvotes: 0

Views: 216

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32770

You should be able to use the "Customize Page Code" field - test the url if your user comes from a domain that requires anonymization and if so set a call to anonymizeip.

if(location.hostname.indexOf('some_site.de') > -1) {
ga('set' 'anonymizeip' true);
}

Since the custom code is run before the first pageview this should work to anonymize the IP for that domain. I admit I haven't tested this, but you can look into the network tab, if the call to the Google servers contains the parameter "&aip" then the IP is anonymized.

Here is a pirated screenshot from the Adobe documentation to show where the Customize Page Code field is (bottom of the image). Hit the "open Editor" field to insert your code.

enter image description here

Upvotes: 1

Related Questions