As an analytics agency, one of the most common questions we get asked by clients is “How can we filter out our internal (staff) traffic if we don’t have static IP addresses”. It’s all very well filtering out traffic using IP addresses – but what happens when your employees (here’s hoping) browser your website at home or whilst they’re on the go. In these situations they wouldn’t be masked by your IP filters (if you had them setup).

Also – not everyone has the luxury of a dedicated broadband line and a fixed IP address. This guide will show you how to remove internal visits so they’re not skewing your data in analytics without the need for static IP addresses. Even better – you can do this retrospectively and turn it off and on at the click of a button using a custom segment.

1. Create A Custom Dimension in GA

First up, we need to create a custom dimension in Google Analytics. This is what we’ll base our filters ‘off of’ so it’s important we get this right. It’s dead easy though so let’s begin:

Navigate to the Admin section of the Google Analytics account you’re wanting to set this up for.

Hit ‘+NEW CUSTOM DIMENSION’ and give it a name that makes sense. We’ll go for ‘Internal Traffic’ in our case.

For the ‘Scope’ – you’ve got a couple of options here and the differences can be a little subtle: If you want to give the user the chance to actually be counted in GA (perhaps employees can also be customers) then go for ‘Session’. This means that for each session an employee has on your website as long as they visit our ‘magic URL’ at least once (at any point) then that individual session will be filtered out. This option allows them the choice to not visit our ‘magic URL’ and therefore have their session counted.

If you want to remove all visits no matter what from employees then choose ‘User’. This means that for the lifetime of your employee’s cookie their visitor data will (or can) be filtered. Here’s what we’re left with – make a note of the Index number (it will be 1 if this is the first Custom Dimension you’ve created).

2. Choose a Magic URL

Now we need to choose our ‘Magic URL’. This is the URL that if you visit, you’ll be registered in Google Analytics as a ‘Internal Traffic’. The quickest and easiest way to do this is to use URL parameters – it saves you having to create a page just for this purpose and is also less likely for someone to stumble onto the page accidentally.

For our example we’re going to go with:

Again – make a note of the parameter you’ve used – we’ll need this in the next step. Once setup, we’ll distribute this to all employees whose traffic we want to filter.

3. Create Variable in Google Tag Manager

NB If you’re still using v1 of Google Tag Manager – you’ll be creating a Macro – but the principal and process is exactly the same. You should also consider upgrading to the latest version of Google Tag Manager though.

Navigate to the your GTM container and create a new Variable:

1. Choose your variable: URL

2. Configure your variable
Variable Name: Internal URL
Component Type: Query
Query Key: traffic

Hit ‘Create Variable’:

When called this Variable looks to see if there is a URL parameter (‘query’) and if there is one it will return the value. The value in our example is ‘internal’. If there is no parameter it will return an ‘undefined’ which is perfect for our needs.

4. Add Custom Dimension to Page View Tag

Now we just need to add this Variable to our standard pageview. You could create a brand new tag just to serve this custom dimension, but in the interest of keeping total tag numbers to a minimum there’s no harm in just adding the custom dimension to your existing PageView tag that fires on every page of your site.

Navigate to the tag and dive into the ‘More Settings’ section and locate the ‘Custom Dimensions’ and hit ‘+ Add Custom Dimension

Index: we made a note of this earlier – in our example it’s ‘1’.

Dimension Value: Click the lego block looking button and find the Variable we’ve just created from the drop down.

Hit ‘Save’ at the bottom of the Tag page and then WE’RE (almost) DONE. Make sure you publish the updated container.

5. Filter Internal Traffic from Google Analytics Reports

There are two ways you can use this newly defined internal traffic to filter it from your reports in Google Analytics:

1. Create a Custom Segment

This is less permanent as you can toggle the filter on and off in your Google Analytics reports.

Navigate to the Custom Segments in your Google Analytics account and create a new one. We’ll call ours ‘Exclude Internal Traffic’.

Select the Advanced>Conditions tab and then select the options as show in this screenshot:

2. Create a Filter

This option is much more permanent and should only be used if you’re sure you never want to see the data from internal traffic in your reports (caveat – we’d always recommend having a view with no filters so you could always fall back to this if you needed to).

For this option you need to navigate to the appropriate View in GA and then within the Filters section, create a new Filter:

That’s it. We’re finished! Thanks for reading and if you have any questions please feel free to leave them in the comments and we’ll get back to you pretty pronto.