SEO

Best Ways to Exclude Internal Traffic in Google Analytics

Do you know the simplest mistake most companies, agencies, and individuals overlook when it comes to reporting monthly numbers?

Have you ever stopped and thought about how many times you visit your clients’ websites in an hour, in a day, in a month? If you aren’t excluding your traffic to your clients’ websites yet, you are about to see how much of an impact you, your agency and/or even your clients’ employees have when it comes down to inflating your numbers. Let’s say a company has 100 employees and, humor me here, all 100 have their company set to their homepage on their laptops. Every day that probably equates to hundreds of visits that are not only inflating your visits but it’s hurting your website’s conversion rate.

So how do we fix this? I am going to show y’all a few different ways that you can make sure you aren’t inflating your own numbers. This ranges from the easiest type of installation to one that may need some developer resources.

Small little tidbit here: *When implementing any of these tactics make sure you set up additional profiles within your existing GA account so you maintain at least one profile that includes all of your Raw Data.*

Please note that for some of these methods shown below I’ve included a ‘shortcut set up’. This is for those that don’t want any explanation and simply want the layout for each implementation.

  1. Google Analytics Opt-Out Browser Plugin – Easy
  2. Creating Custom Filters Based on IP – Medium
  3. Creating Custom Filter Based on ISP – Medium
  4. Set a Cookie with JavaScript – Hardest

Pro Tip 1: Make sure to test your filters prior to rolling them out to any profiles that are already being used for reporting purposes.

Google Analytics Opt-Out Browser Plugin

This wonderful browser add-on is by far the easiest to implement. Simply have everyone whom you wish to block from sending Google Analytics data download the Google Analytics Opt-out Browser Add-on. Website visitors that download this add-on will no longer be sending visitor data to Google Analytics. This add-on prohibits the GA JavaScript from sending visit information. You do not have the ability with this opt-out extension to decide which sites you opt-out of sending information to Google Analytics, so if you want specific information sent make sure you disable the extension.

Pro Tip 1: Make sure that you install the opt-out add-on to all user profiles you have set up, as well as on all browsers, computers, tablets and basically any device that can get you to a website (because the add-on only works on the profile within your browser that you have it enabled on).

Pro Tip 2: Don’t forget you have this add-on enabled! If you often run tests in GA using yourself as a visitor to see if your tracking is running properly, make sure to either turn the add-on off while running your tests, or use a different profile (or the incognito option).  I know this sounds pretty obvious but I myself fell victim to this once and it took me 10 minutes to realize my tracking was actually correct and I was just blocking my traffic to GA. Lesson learned there!

Creating Custom Filters Based on IP

Single IP Address

First, do you know what your IP address is? No! Then go here. Now follow the step-by-step instructions below:

Go to the Admin Section of Google Analytics

Select the Filters Tab

Select New Filter

Select ‘Create new Filter’

You can use either a predefined filter or a custom filter for a single IP address. The example below shows the configuration for a predefined filter. All you need to do is name your filter, place your IP address in the section provided and save.

Single_IP

Range of IP Addresses

Here we will be creating a custom filter to exclude a range of IP addresses.

Go to the Admin Section of Google Analytics

Select the Filters Tab

Select New Filter

Select ‘Create new Filter’

Filter Type: Custom Filter

Exclude Filter Field: IP Address

Filter Pattern: Input your IP Address Range (Guys, this easy tool automates the RegEx for you!)

range ip

Creating Custom Filters Based on ISP

There are a few ways you can approach excluding traffic via your Internet Service Provider since, once again, we have the option of using either a predefined filter and/or a custom filter. There are also 2 ways to exclude an ISP from Google Analytics; the first is by ISP domain while the other is by ISP organization. See the difference? If not that’s okay all it means is that you are either using the registered name you have given to your ISP or you are using the geographic domain of the ISP.  When using the predefined filter you are only given the choice to exclude the ISP domain.

ISP Domain

Go to the Admin Section of Google Analytics

Select the Filters Tab

Select New Filter

Select ‘Create new Filter’

Filter Type: Predefined Filter

Exclude traffic from the ISP domain that are equal to

From ISP Domain: Insert ISP Domain

isp domain

ISP Organization

Using a custom filter and an ISP organization would look like this:

Go to the Admin Section of Google Analytics

Select the Filters Tab

Select New Filter

Select ‘Create new Filter’

Filter Type: Custom Filter

Exclude

Filter Field: ISP Organization

From ISP Domain: Insert ISP Organization

isp org

Pro Tip 1: You typically want to watch how you name your ISP. For example, if your ISP is named after your company and you are constantly going to a competitor’s website, they can go in to their own GA and look at Service Provider data and see traffic coming from your company.

Pro Tip 2: You probably don’t want to exclude a cable/internet/wireless/broadband provider, since you’ll take out all of the visitors who use that same provider.

Set a Cookie with JavaScript

If you have come to this section then you want a little more advanced approach to filtering out your internal traffic. So, if you have seen all the previous blog posts people have written about using cookies to exclude internal traffic you have probably seen the code incorporate _setVar(). Well Google has noted this method is deprecated and recommends the use of _setCustomVar() instead. Here’s the deal people, _setVar() still works! But, for those who do not want to use the _setVar() method you can use _setCustomVar(). I am going to give y’all both scripts, but there is one major difference between these 2 methods when setting them up in Google Analytics. _setVar() is called within Google Analytics filters using the Filter Field: User Defined. _setCustomVar() can’t be called with the Filter Field: User Defined. So what does that mean and why should you care? You should care because _setVar() allows you to create a profile filter that can exclude your traffic and _setCustomVar() makes you use an advanced segment to filter out data. So _setCustomVar() will filter the data not as it comes in like a profile filter will but it will filter all the data after it has already been passed to GA – meaning if you have a larger site you will probably be using an advanced segment with sampled data.

_setVar()

_setVar() allows you to define a user value(our example uses the value of ‘employee’) that gives you the ability to segment your data. With _setVar() you want to create a new HTML page that is only accessible to those who are given the new landing pages URL destination. You don’t want everyday visitors accidentally stumbling across this page resulting in you then losing out on all of their data. Once you have your new HTML page created, implement the code below. The only thing you need to change is make sure you change ‘UA-XXXXXXXX-1’ to your actual UA code. You’re not done yet! Why? Because you still need to set up a filter within GA to actually exclude your defined value for those who have been exposed…

The filter should look like this:

Go to the Admin Section of Google Analytics

Select the Filters Tab

Select New Filter

Select ‘Create new Filter’

Filter Type: Custom Filter

Exclude

Filter Field: User Defined

Filter Pattern: employee

Now you have a specific profile (if you read the beginning of my post, which you should have) that will filter out data for users that have been cookied after visiting this page. Make sure that you have your employees, developers, agency, or whoever you want to exclude, visit this page on every computer, device and profile they may use (otherwise it will only work for the device that they visited the page on).

Pro Tip 1: If you clear your cookies you will need to make sure that you revisit this page.

Pro Tip 2: You can change ‘employee’ to be anything your heart desires. Update the code as well as the Filter Pattern in GA to match whatever you change this value to. But make sure you name it something unique so you don’t mess with any other filters you may have in place.

setvar

_setCustomVar()

With _setCustomVar() there are a few more steps you need to take to implement this strategy. You see we have 4 fields within the code that we need to fill out unlike with _setVar() where we just had to define the value as ‘employee’. Here is the layout for how to set up Custom Variables within your source code _setCustomVar(index, name, value, opt_scope). See Google’s breakdown of the _setCustomVar() parameters if you want more information.

Index: 1

Pro Tip 1: This is the slot used for your custom variable. There are 5 slots and you can choose between the 1-5 range when setting slots. A custom variable should be placed in one slot only; these can be overwritten so make sure you are using an open slot.

Name: employee

Pro Tip 2: You can change ‘employee’ to be anything you heart desires, just like with _setVar. Update the code as well as the Custom Variable Key (for the advanced segment) in GA to match whatever you change this value to.

Value: Yes

Opt_Scope: 1 (This sets the cookie to the visitor-level)

Pro Tip 3: opt_scope has 3 levels 1=visitor-level, 2=session-level and 3=page-level

set custom var

After this you need to set up an advanced segment to apply when looking at your data. Again as a reminder, using _setCustomVar does not allow you to implement a profile filter but uses an advanced segment. To create an advanced segment simply select the advanced segment tab and select New Custom Segment (reference here).

Setting up your advanced filter:

Exclude → Custom Variable (Key 1) → Exactly matching → employee

And

Include →Custom Variable (Value 01) → Exactly matching →Yes

All we are declaring in this advanced segment is to exclude data from the custom variable in slot 1 that is called employee AND includes the value (attributed to slot 1) of Yes.

advanced segment

Click here to simply copy the advanced segment above.

ZIESSLER STYLE SHORTCUTS

This is the quick and dirty approach to everything above without all the garbled text.

Single IP Address

Filter Type → Predefined filter

Exclude → traffic from the IP addresses → that are equal to

IP address → Insert IP address

Range of IP Addresses

Filter Type → Custom filter

Exclude

Filter Field → IP Address

Filter Pattern → Insert range of IP addresses

Custom Filter Based on ISP Domain

Filter Type → Predefined Filter

Exclude →  traffic from the ISP domain →  that are equal to

From ISP Domain → Insert ISP Domain

Custom Filter Based on ISP Organization

Filter Type → Custom Filter

Exclude

Filter Field → ISP Organization

From ISP Domain Insert ISP Organization

_setVar

setvar

Filter Type → Custom Filter

Exclude

Filter Field →  User Defined

Filter Pattern → employee

_setCustomVar

set custom var

Advanced Segment Here

I hope this is helpful and provides guidance when you’re selecting the best option available for your client, company, agency, etc. Good Luck!

What other methods do you use to exclude visitors from inflating your data? Let me know in the comments below and follow me on Twitter for more insights @ziesslerk.

Check out our open positions!