Fed up with filtering dynamic IPs for internal traffic? Try the Local Storage method here. We will be using combination of – Browser Local Storage, GTM and GA Filters to filter out internal traffic.
We set a LS (local storage) key for internal traffic with GTM and value of this LS will be used as a custom dimension in GA. Inturn at the GA filter setup, we will exclude user traffic with this value.
StepsSetup a Custom HTML tag with JS code to set a Local Storage key when a user lands on a unique URL like this:
We are setting up a unique URL like above so its easy to set LS key for internal users by just giving an URL to visit.
Here is the Custom HTML TAG to be used:
<script> window.localStorage.setItem('internal_traffic', 'true'); </script>Now create a TRIGGER to fire this script at page views that contain the unique URL strings we mentioned in STEP 1.
Java Script variablewith name
internal_traffic_lsin GTM to fetch the LS value.
userscope custom dimension in your Google Analytics account and add that to GTM GA Settings.
If you don’t know how to create custom dimension read this article.Create exclude filter at Google Analytics, to filter out all traffic that contains
truefor your filtered traffic view.
Publish and we are all done. Reach out to co-workers to click on custom URL you setup
[ NOTE: that first page load for this URL will be recorded in GA as LS value will be undefined; Successive pageviews will get filtered]