This is a follow up tutorial to my previous article about adding Google Analytics to your website. In this guide I’m going to explain how to exclude yourself from Google Analytics.

If you’re a website owner you probably visit your website multiple times every day. Even more so if you’re developing a website since you need to refresh the website multiple times within a few minutes to see if the changes you made work.

All these visits are going to make your analytics data inaccurate. And in large businesses internal traffic can be quite significant, for example during stress tests. So how do you exclude yourself, or your entire company from showing up in Google Analytics data?

There are multiple ways. Some of them are better than the others so it’s up to you to decide which method is best for you.

1. Exclude using a browser extension

The easiest method is by using an official browser extension from Google, which is available for almost all modern web browsers (except Microsoft Edge).

This extension forces the analytics tracking code to ignore all visits from browsers the extension is installed on. In other words, you’ll be invisible to all websites with Google Analytics installed, which is the most used analytics service in the world.

2. Using a WordPress plugin

If you don’t want to be completely invisible for all websites but just your blog then a WordPress plugins is more suitable.

For example, Google Analytics by WebKinder allows you to set a cookie for logged in users, which won’t track you (since you’re the admin and always logged in) and everyone else who has access to your admin area.

Quite useful when you have more than one author who constantly visits your website to write content.

Another similar plugged is called Ank Simplfied Google Analytics, where you can specifically choose who gets tracked who doesn’t. The downside to this method is if you’re running a membership website then all logged in members may also be invisible. So make sure the plugin has options to determine which type of logged in users it should track and which it shouldn’t.

3. Exclude using the hosts file

Another way of excluding yourself from getting tracked by Google Analytics is via the hosts file on Windows, or Mac. Hosts file maps hostnames to IP addresses.

By mapping Google Analytics tracker to localhost (127.0.0.1)  your computer won’t be able to access the tracking domain. Don’t worry, the tracking domain is not the same as the analytics domain so you’ll be able to access Google Analytics without any problems.

To map analytics hostname to localhost we need to do the following:

  • Locate the hosts file inside Windows directory
  • Open the file in a notepad, or other text editor
  • Map secure and unsecure domains to localhost

Location of hosts file in Windows

In Windows the hosts file is located in the following directory: This PC > C Drive > Windows > System 32 > drivers > etc

If the file isn’t visible make sure you have Show hidden files enabled.

For Mac users I suggest you follow this tutorial.

Locations of the hosts file in Windows 10

Right click the file named hosts and press Copy. Then right click an empty space inside the folder and click Paste (or simply select the file and press CTRL+C and CTRL+V). Now you have a copy of your hosts file – this is a backup in case something goes wrong (no worries, it won’t).

Editing the hosts file

Next, open the original file with Notepad, or any other text editor, and add the following two lines at the end:

  • 127.0.0.1 www.google-analytics.com
  • 127.0.0.1 ssl.google-analytics.com

Editing hosts file in notepad on Windows 10

Just make sure there’s at least one space between the IP address and the domain name. Save the file and you’re done.

Note: Windows may ask for administrator’s permission, just click Continue. However, if you’re not the administrator then you won’t be able to make changes to the hosts file.

4. Exclude using an IP filter

The next method of excluding yourself from Google Analytics is by using filters, which can be found in the analytics admin area. This way is more suitable for those with a static IP address. Unlike a dynamic IP address static IP does not change every time you connect to the internet. This means you don’t have to modify filter parameters every time you restart your computer for example.

To create an IP filter you need to do the following:

  • Find out what’s your IP address
  • Check if the IP is dynamic
  • Create an IP filter in Google Analytics

Find out your IP

The first step is to find out your IP address. You can do so by entering “what’s my ip” into Google’s search field, or going to WhatIsMyIP.com.

Google results for the term "what's my ip

Check if your IP is dynamic

Next you need to figure whether you have a dynamic IP address or not. To do this write down your IP address from the previous step and restart your router. If it’s a different one then you have a dynamic IP address, and this method is impractical.

However, if you have a static IP then proceed to the next step.

Create an IP filter inside Google Analytics

Login to Google Analytics and go to the Admin panel.

Under View find and click on Filters.

Filters in Google Analytics

Click Add Filter.

Now follow instructions on the screenshot below.

How to add an IP filter in Google Analytics

That’s it, now you shouldn’t see yourself in the analytics data.

In conclusion

There are various reasons to exclude yourself from Google Analytics, there are also many ways to do it. Some ways are better than others. If you’re a blogger who doesn’t want to see your own visits – since it messes up the data – then the best way to do it is to install a WordPress plugin, which lets you disable tracking for logged in users.

However, if you’re a developer, or just a privacy concerned web surfer then excluding yourself by editing the hosts file in Windows, or installing a browser plugin is by far the most superior method as it blocks the tracking script entirely.

Anyways, I hope this guide was helpful and now you won’t see any fake visits in your statistics.

Was this guide helpful? Do you have other ways of blocking tracking codes? Tell me in the comments below!