4 tips on how to exclude the traffic from the home offices

Claes Hedlund

The spread of the coronavirus has led to an unusual number of people working from home. This post is about how current circumstances can affect your site’s analytics data – or rather, how to avoid being affected.


Most organizations use filters for internal traffic – features that exclude visits from the organization’s own IP address. Why? Because they want to avoid employees’ behavioral data from polluting other external behavioral data. 

Why would it do that? Because the behavior of the employees does not correspond to external visitors. We want to gain insights and make decisions based on the behavior of our external visitors, not the employees. Therefore, in most cases, it is important that these be separated.

Are there organizations that are more spared from the impact of internal traffic than others? Yes, those who have very large traffic volumes. This depends on the relationship between the number of employees and the number of visitors.

It is usually not very complex to exclude internal traffic. In tools such as Google Analytics, Adobe Analytics and Matomo allow you to exclude traffic based on which IP address it comes from. All you need to do is identify the organization’s (and possibly consulting companies) IP addresses and set up a simple filter *. But with the current state of things, a little more work will be required.

Please note that if Google Analytics uses the IP anonymization feature, view filters will not work based on IP addresses – neither now or before the outbreak of the Coronavirus. However, Adobe and Matomo have standard solutions for the combination of IP filtering and IP anonymization.

So: since many employees now work from home – and we don’t know how long this will continue – we need to find other solutions, regardless of what analysis tool we’re using. In this post, we will focus on solutions made in Google Analytics and Google Tag Manager.


So how do we exclude internal traffic from our reports? If the employees who work from home use the organization’s VPN service, it is sufficient to exclude these IP addresses, in case they are static. However, many organizations do not use VPN services, so we have made a list of suggestions on how to get around the problem, and it looks like this:

  1. Gather all employees IP-addresses, and exclude traffic from those

Not recommended for organizations where more than, let’s say … a dozen people use the site in their work. This solution also does not work for dynamic IP addresses.

  1. Ask all the employees to install a browser extension that blocks the use of analytic tools

This is also only recommended for smaller organizations, as long as IT cannot install the extension on all different units within the organization. However, using different browsers can be tricky. Either way, for Chrome users this extension can be used.

  1. Get all the employees to use a specific URL when they visit the site, and from there on create a filter to exclude them with the help of a custom dimension
  2. Create an internal page with links for all the meetings – set cookies, and use these to exclude the traffic

The solutions for 3 and 4 are most effective, especially for bigger organisations, these are the ones we will focus on and guide you through.

Query Parameter as an identifier

This method is based on a post made by the GTM-Guru Simon Ahava.

Solution #3 involves adding a parameter to the site’s URL (www.example.com?internal=true), a so called query parameter, to then be able to pick up that information and use a custom dimension in order to filter out traffic.

Step 1: Create a Custom Dimension in Google Analytics

Create a new Custom Dimension in Google Analytics: Admin → Custom Definitions → Custom Dimensions. Give the dimension a descriptive (e.g. Internal Traffic) and set the scope to User.

Please note that the index of the dimension (3 in this case) is the index that we want to use later on.

Step 2: Create a variable in Google Tag Manager

Go to Variables → User-Defined Variables → New.

Variable Type: URL
Component Type: Query
Query Key: internal

The Query key is thus what stands after the question mark in the URL – our query parameter.

Name the variable to something descriptive, e.g. URLInternal Traffic → save.

Step 3: Configure the Pageview-tag

Open the Pageview-tag that is being used in Google Analytic → tick the Enable override settings in this tag → More Settings → Custom Dimensions.

Index: 3 – the index number in Google Analytics.

Dimension Value: {{URL – Internal Traffic}}the name of the variable you just created.

Note that this can also be done directly in your Google Analytics Settings-variabel.

Step 4: Try it!

Use the Google Tag Managers Preview Mode. First visit the site without the query parameter (www.example.com). Explore the Pageview-tag in the debug-panel. We should see this:

Since we didn’t have the query parameter in the URL:en, the value for the dimension is undefined.

Then visit the site with the query parameter (www.example.com?internal=true).

Here we see that the value for the dimension becomes true. The value is being picked up in our Custom Dimension.

Step 5: Set up a view filter i Google Analytics

In Admin → View → Filters, click + Add filter. The configuration looks like this:

Filter Type: Custom
Exclude: Internal Traffic (the name on our new Custom Dimension)
Filter Pattern: true

In this way, we can filter out all the users who visited the site with the associated query parameter. Don’t forget to give the filter a descriptive name, e.g. Exclude internal traffic (or Exclude internal traffic – Query if the IP filters already exist, in order to distinguish them).

Step 6: Get all the employees to visit the site

Now for the final and the toughest step. There are different strategies in order to get the employees to visit the site with the associated query parameter:

  • Send out a link and ask everyone to click on it
  • Ask everyone to bookmark the link, or even better: ask everyone to add it as their homepage in their browser.

If the employees clear their cookies often or use a browser such as Safari, it’s important that they visit the site regularly with the query parameter.

If there is an IT department that has the opportunity to set the site as the homepage for all devices and browsers, this might be a good idea.

Option: bookmarklet that adds a cookie

One alternative of adding the query parameter is to ask the employees to bookmark a script that creates a cookie, a so-called bookmarklet.

Kudos to Elin Ledenvik for this script! Click on the image in order to get to the text file! 👆

Copy the script and add as a bookmark. (In Chrome: open a new tab → go into Bookmarks in the menu → select Bookmark this tab… → paste the script in the URL-field → save.)

When you then navigate to the site and click on the bookmark, a cookie is set. The information stored in the cookie we can then pick up with a 1st-Party Cookie variable in Google Tag Manager. More about how this works in solution number 4. (Note that in the script above, the cookie is named to employed, but this can, of course, be adjusted according to taste.)

This solution is also sensitive in such a way that all employees themselves must bookmark the script and set the cookie.

Link to meetings via internal site – and set cookies.

This is probably the best solution for slightly larger organizations. This solution involves setting cookies on internal pages under the same domain (www.example.com/internal/). So it should be a page that external visitors never visit and that is not indexed by search engines.

Many organizations use communication tools such as Skype, Google Hangouts, Whereby, Microsoft Teams etc. This is something we can use to place cookies in the employees’ browsers, thus filtering out traffic. The idea is that instead of sending links directly to meetings, these links are placed on an internal page.

Please note that not all smaller meetings need to be posted on this page. However, it is good if you have regular “all-hands” meetings. Regular visits are also important here if the employees use web browsers with tracking protection or clear cookies frequently.

Step 1: Create an internal page for meeting links

Exactly how it’s done varies of course from organisation to organization. The most important thing is, as mentioned above is that it’s a page that is not visited by anyone other than the employees and that is not indexed by search engines.

Step 2: Create a custom dimension in Google Analytics

This step is identical to step 1 in the previous solution. If both methods are used, remember to give the Custom Dimensions that you created different names.

Step 3: Create a cookie in Google Tag Manager

In this step, we’re using a cookie script from quirksmode.org.

Create a Custom HTML-tag, and add the following script:

Click on the image in order to access the script! 👆

With this design, the cookie ceases to exist after 1000 days (this is specified on line 11, when the function is called). Of course, this can be adjusted according to your needs.

Give the GTM-tag a descriptive name such as Set cookie – Internal traffic, and save the tag.

Step 4: Create a trigger

Now we need a trigger that ensures that the cookie only is set on the internal page.

Create a new trigger → set Page View as trigger type → select Some Page Views → specify that Page Path equals* /internal/ (the path as the internal page has, e.g. www.example.com/internal/). Name the trigger to. PV Trigger – Internal page → save.

Make sure that the tag from the previous step uses this trigger.

*If there are multiple internal pages under the same path, contains can be used as a condition instead of equals.

Step 5: Create a variable

Go to Variables → User-Defined Variable → New.

Variable Type:
1st-Party Cookie
Cookie Name: internal*

*If you have changed the name in the cookie script in step 3, you use the new name here.

Name the variable to e.g. Cookie – Internal traffic → save.

Step 6: Configure the Pageview-tag

This step is the same as step 3 in the previous solution. Use the dimension index from Google Analytics and use the cookie variable as the dynamic value. This can be done either in the Pageview tag or in the Google Analytics Settings variable.

Step 7: Try it out!

Use Google Tag Managers Preview Mode. First, visit the website’s homepage (www.example.com). In the debug panel you should now be able to see the set cookie tag (Internal traffic) under Tags Not Fired On This Page.

Then visit the internal page, and make sure the tag is fired there. We can also check in the browser that the cookie has been set. Next to the browser’s address bar, there is usually an icon (depending on which browser is used) in the form of a padlock or an exclamation point. If you click there you can inspect cookies. Here’s how it looks in Chrome:

Under the organization’s domain, we can check if the cookie has been set.

Make sure that the cookie only is set on the internal page and not on, for instance, the homepage.

Step 8: Create a view filter in Google Analytics

Under Admin → View → Filters, click on + Add filter. The configuration looks like this:

Filter Type: Custom
Exclude: Internal Traffic – cookie (the name of our new Custom Dimension)
Filter Pattern: true

Once set, all visitors who visited the internal site will be filtered out. Don’t forget to give the filter a descriptive name, e.g. Exclude internal traffic (or Exclude internal traffic – Cookie if IP filters already exist, to easily distinguish them).


Something that is also very handy about these solutions is that we go around the problem of the combination of IP anonymization and view filters. IP anonymization is recommended to comply with GDPR. However, the use of IP anonymization means that the IP addresses are anonymized before being stored on Google’s servers. The view filters are applied after the data has been stored, which is why this is usually a problem (as it is suspiciously talked about).

This is an extended version of Google’s model.


No matter which solution we choose, some work will inevitably be required – either by the employees themselves, by IT or by the person responsible for creating and updating the internal site. Hopefully, everyone is prepared to do the little extra in times like these to get the work done!

Hope you can make use of these tricks to ensure good data quality – whether we work together now or if, hopefully, we will do so in the future!

Read also

Conversionista is open for business in The Netherlands.
Conversionista is open for business in The Netherlands. Read more.