COVID-19 has driven the majority of office workers to a new reality of work from home (WFH). Besides the usual challenges this brings (e.g. Zoom meetings with kids screaming in the background), this also poses a challenge for Web Analysts.
In the good ol’ days, pre-COVID, we could simply exclude the office IP or even an entire IP range to remove all internal traffic from reports. But in this new reality, with all our workforce split across countless everchanging IPs, a different solution is required.
In this post, I’ve gathered some of the top Google Analytics experts to share their ideas for dealing with such traffic.
Conceptual framework
When considering such an exclusion strategy, we need to consider two things:
How can we identify only the internal traffic?
In absence of an IP or even an IP range, another technique is required to identify the users. In this post I’ll suggest several ways to proactively flag these users.
What is the exclusion technique?
Do we block them at the source (i.e. stop GA from firing for them) or filter them out in GA (after highlighting them in the browser).
I generally find it easier to block at the source. The flip side is that for testing purposes (e.g. verifying that a form submission is tracked) you’ll need to disable the blocking mechanism. In this post I have examples of both techniques.
Vanity URL
This solution was suggested by Thomas Bosilevac from MashMetrics.
“Send your internal users a link to a URL with a parameter that will mark them as internal traffic, for example mysite.com?exclude=true.”
Using Google Tag Manager, you can easily create a script (using a Custom HTML tag) that captures this parameter and saves it in a browser cookie.
First check if the cookie value exists, by creating a variable that captures the URL Parameter of the name “exclude”
Then use variable to check its value and sets the cookie value accordingly.
<script>
if ({{Exclude parameter}} == true) {
document.cookie = "exclude=true";
}
</script>
Finally, create a variable to capture the value of the cookie.
This cookie value can then be used as an Exception Rule for your tags in GTM.
Create a new trigger for All Pages that exclude the
Add this trigger as an Exception for you GA tag.
Redirect URL
This solution was suggested by Erez Louzon from ThinkUser.
“For more technical teams, I suggest creating a redirect URL (on your main domain). A user navigating to this URL will be redirected to the homepage using a Javascript redirect, while a the browser storage is set with the exclusion parameter.”
Similar to Vanity URL solution, this value can be picked up in GTM and used as an Exception Rule.
The general outline of such a page will include this code:
<!DOCTYPE html>
<html>
<head>
<title>Internal Traffic Exclusion</title>
</head>
<body>
<script>
function redirect() {
document.cookie = "exclude=true";
window.location.replace("https://www.example.com")
}
redirect()
</script>
</body>
</html>
The function sets browser cookie item called “exclude” to true. This item will also be available if the user returns again from the same browser.
It then redirects the user to a new page. You can replace the target URL with your own site.
To capture this in GTM, simply create a variable that captures the values of the cookie “exclude” as described above.
Custom Dimension
This solution was suggested by Or Blan from Ynet.
I prefer to flag the internal traffic using a Custom Dimension. This way I can exclude them from my work Views in GA and still view them in my backup view for testing purposes.
To set up this you will need to first, create a Custom Dimension in Google Analytics with a relevant name, for example “Internal traffic”.
Next, grab the dimension index, e.g. 01, and add it to the Google Analytics Settings variable in GTM (under More Settings -> Custom Dimensions). The Dimension Value should be set to the Exclude cookie as described above.
Once this is set up in GTM, you can return to GA to create the filter.
Set the Filter Type to “Custom” and select the Custom Dimension you created. The filter pattern should be set to “true” (the value sent in the Custom Dimension).
Update: Excluding all hits
A good tip I’ve received from my friend Shuki Mann of LixFix:
Excluding only Pageviews isn’t always enough, as many sites also track other interactions such as scroll depthor video views. In such a case excluding all hits is the key to a clean account.
Shuki also shared his recipe for success:
Create a Lookup Table variable that takes in the Exclusion Cookie value. If it’s set to true, fire a different Analytics UA (e.g. your staging environment’s UA), else default to your regular Analytics UA.
Use this variable in your GA Events and Pageview tags.
Google Analytics Opt-out Add-on
This solution was suggested by Daniel Saada from Blocket.
“A simpler solution I’ve found for large scale teams, it to simply encourage them to install the GA Opt-out extension on their browser. In some companies, the IT can even enforce that these extensions are installed”.
This browser extension, offered by Google, completely block any Google product on the site. This can block a GA script installed directly on the site or via GTM.
The extension can be downloaded on this link, and is compatible with all major browsers:
Google Chrome, Microsoft Edge, Mozilla Firefox, Apple Safari and Opera.
Ad blockers
Another, more aggressive alternative is to have your users install an ad blocker on their browser. This will effectively block the GA script from running.
The most efficient ad blocking solution is uBlock Origin, which also works across all major browsers:
Google Chrome, Microsoft Edge, Mozilla Firefox, Apple Safari and Opera.
Summary
Solution | Pros | Cons |
---|---|---|
Vanity URL | Easy to set up | Dependent on cookies/local storage |
Redirect URL | Less GTM set up | Requires adding a page to the site |
Custom Dimension | Minor GTM set up | |
GA Opt-out Add-on | Bulletproof blocking No GTM alterations | Works on Desktop only |
Ad blockers | Bulletproof blocking No GTM alterations |