Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Anonymization of IP adresses with Google Tag Manager

238 views

Published on

How do you anonymize your IP adresses, while still being able to see how your internal traffic is performing? In this presentation for #mccph18, I did a discussion around the topic.

Published in: Data & Analytics
  • Be the first to comment

  • Be the first to like this

Anonymization of IP adresses with Google Tag Manager

  1. 1. COPENHAGEN MEASURECAMP 2018 ANONYMIZATION OF IP ADRESSESES WHILE STILL EXCLUDING INTERNAL TRAFFIC June, 2018
  2. 2. • Lead analyst at IMPACT EXTEND • Lives in this city • 6th measurecamp Who am i?
  3. 3. THE WAY WE ARE CURRENTLY EXPERIMENTING WITH IT
  4. 4. User enters the site If the user is internal Set cookie isInternal Check for cookie in GTM Use lookup table to set anonymize IP to nothing If the user is external Set cookie isExternal Check for cookie in GTM Anonymize IP Script checks if IP is internal or external How it works
  5. 5. Why should you care?
  6. 6. YOU SHOULD CARE IF YOU WANT TO EXCLUDE INTERNAL TRAFFIC
  7. 7. HOW IT WORKS
  8. 8. • First pageview will always be anonymized as no cookie is set • Script is fired to check the users IP with a regex • To find what IP adresses that should be excluded you need to grab them from your current Google Analytics settings 1. USER VISITS THE SITE AND GETS A COOKIE var client = new HttpClient(); client.get('https://api.ipify.or g?format=json', function(response) { var result = JSON.parse(response); var ip = result.ip; var ipInternal = /^((94.231.106.19)|(217.195.188 .30)|(94.231.104.(1[6-9]|2[0- 9]|3[0-1]))|(93.176.86.(19[2- 9]|2[0-5][0-9]))|(94.231.99.(1[6- 8][0-9]|19[0- 1]))|(80.198.126.162)|(192.168. 126.162)|(93.176.86.194)|(93.17 6.86.209)|(50.23.94.74)|(46.20 .45.18)|(94.46.4.1)|(108.62.1 15.226)|(69.64.56.47)|(46.165. 195.139)|(94.247.174.83)|(199.8 7.228.66)|(76.72.167.90)|(184. 75.210.186)|(93.176.86.252)|(94 .231.99.)|(3[2-9]|[4-5][0-9]|6[0- 3])|(5.56.154.58)|(212.237.134 .78)|(93.176.86.149)|(93.176.86 .149))$/i;
  9. 9. 1. USER VISITS THE SITE AND GETS A COOKIE
  10. 10. 1. USER VISITS THE SITE AND GETS A COOKIE If IP matches an internal one – set the cookie as internal - Else do the opposite
  11. 11. 2. GRAB THE COOKIES YOU JUST SET
  12. 12. 2. GRAB THE COOKIES YOU JUST SET
  13. 13. • Make sure that the you choose an appropriate time period to save the cookie in the browser • Set a triggerrule on pages to not fire the script if the cookie is already set – the developers will love you for it • The developers will probably not love you for it, they will probably be annoyed that you are adding code on their website • I will also present a version where the developers do all the technical stuff for you – no worries! 3. MAKE SURE IT DOESN’T FIRE ALL THE TIME!
  14. 14. 4. WRITE A SCRIPT TO RETURN IF THE USER IS INTERNAL function () { var returnValue = "true"; var external = {{cookie - External traffic}}; var internal = {{cookie - internal traffic}}; if(external == 1) { returnValue = "true"; } else if (internal == 1) { returnValue = "false"; } else { returnValue = "true"; } return returnValue; } • The script checks the cookie and finds out weather the user is internal or external. • We are using this to create a boolean value to which we can send the value through a custom dimension (not needed though)
  15. 15. 5. USE IT IN A CUSTOM DIMENSION IF YOU NEED TO EXCLUDE TRAFFIC WITH THAT!
  16. 16. 6. IF YOU ARE EVEN MORE LAZY, ANONYMIZE IP ADRESSES WHEN IT HITS GA,AND PREVENT CHANGING YOUR CURRENT SETTINGS !
  17. 17. WHERE DOES THIS LEAVE US?
  18. 18. 1. Exclude IP adress through your current GTM Filters • Quite nice, as you can just keep your current settings • It does however provide a threat as you are not anonymizing all IP traffic, and it is possible something you have to talk about with your vendors and consultants. 2. Exclude based on the custom dimension • Data is already avaliable from the custom dimension, so dividing internal and external is easy • It does however take a bit longer than the first solution 3. You could also make your developers do it • If you have a list of IP adresses that should be included, you can make your IT department expost them as a boolean ”internal or external” value in the datalayer • You do however have to fight with the IT guys to make it happen THIS LEAVES US WITH A LOT OF OPPORTUNITIES!
  19. 19. WHAT DO YOU GUYS THINK ABOUT THE SOLUTION?

×