Blocking Internal Traffic in Google Analytics with Cookies
Fed up with filtering dynamic IPs for internal traffic? Try the cookie method here along with regular IP filters. We will be using a combination of – Browser Cookie, GTM and GA Filters to filter out internal traffic.
Logic
We set a domain-wide cookie for a specific URL accessed by the internal users with GTM (example - yourwenbiste.com?internal=true ), and the value of this cookie will be used to create a filter that will exclude internal users at GA.
Steps
1️⃣ [GTM] Create Custom HTML tag to set Cookie
And add a trigger to fire on page views that contain "internal=true'
This tag will set a domain-wide cookie named "internal with value true" - whenever an internal user visits the website
💡 I would also trigger this cookie tag for URLs containing "gtm_debug=" as this will exclude me when previewing GTM in incognito/private mode.
2️⃣ [GTM] Create Cookie value variable
Now that cookies are set next, we need to fetch the value of the cookie whenever available and pass it to Google Analytics for filtering.
For this, create a new variable of "1st Party Cookie" type with cookie name "internal"
3️⃣ [GA] Create Custom Dimension & Filter in Google Analytics
Create a user scope custom dimension in Google Analytics and name it "Internal User" and create a filter in "master/main" view to filter to exclude all internal users with value "true"
4️⃣ [GTM] Add Custom Dimension to Google Analytics Settings
Expand "More Settings" at Google Analytics setting variable and "Custom Dimensions" within it, then add the variable created at step 2️⃣
For the custom dimension "index" refer to the custom dimension section in Google Analytics. (remember that index should not be the name of the custom dimension created)
5️⃣ Now ask all co-workers to visit - yourwenbiste.com?internal=true - on all their devices/browsers
CONS of this method:
Cookies are browser-specific, cookies will be set only on the specific browser this link was accessed, if a user accesses the website with - a different browser, incognito/private modes this will not work.