How To Use Google Analytics View Filters To Exclude Multiple IPs

29Shares

Google Analytics View Filters To Exclude Multiple IPs
  • Save

Setting up Google Analytics is easy. You simply have to install the Google Analytics tracking code on the site and BOOM! Data starts flowing through your dashboard.

Right? WRONG!

One of the biggest mistakes most people make while setting up Google Analytics is they DON’T exclude internal IPs, and you may be one of them.

How many times in a day do you check your own (or your client’s) website? Once? Twice? More than ten times? If it’s more than that, you have skewed data.

The solution is to use the view filters to exclude yours and your client’s IPs from getting tracked in Google analytics.

Let’s take a look at how you can exclude:

  1. Subnet Of IPs
  2. IP Ranges (Sequential)
  3. Random IPs

How to Exclude Specific IP’s from Google Analytics for better reporting:

#1 Exclude Subnet of IPs

Let’s say you want to exclude all the subnets of IPs starting with 192.168.0.x, where x is any number.

You can create a view filter with type as ‘predefined’, then select ‘exclude traffic from IP address that begins with‘ and paste the starting part of an IP  ‘192.168.0’

Google Analytics View Filter Exclude IP Subnet
  • Save

Doing so will filter out all the IPs starting with 192.168.0

For Eg: 192.168.0.1, 192.168.0.2, 192.168.0.3 and so on…

Save the filter and you’re good to go.

 

#2 Exclude IP Range (Sequential)

IP Range can be any range of sequential IPs, for eg:

  • 192.168.0.0 – 192.168.0.9
  • 192.168.0.10 – 192.168.0.19
  • & so on…

I have seen a lot of people creating ten different filters for each IP, a very time-consuming job. The best way is to use REGEX to exclude the group of IPs in a single filter.

Here’s how you can do it.

  1. Go to view filters and create a new one.
  2. Choose Filter Type as ‘Custom’ and Filter Field as ‘IP Address’
  3. Add ‘^192\.168\.0\.[0-9]$’ in the filter pattern

Google Analytics View Filter Exclude IP Range Sequential
  • Save

The above example will exclude IP range from 192.168.0.0 to 192.168.0.9 (10 IPs).

I won’t go into much details about regex, but remember these basics:

  • ^ – denotes the start of the string
  • $ – denotes the end of the string
  • | – denotes the ‘OR’
  • \ – denotes the escape character.
  • [0-9] – denotes any number from 0 to 9

Lastly, save the filter.

#3 Exclude Random IPs

Well, most of the times you need to exclude the IPs of your home, office, mobile, and clients.

These IPs are neither sequential nor a part of the same IP subnet; they are random.

In that case, you can simply use the ‘OR’ in Regex which is denoted as ” | “. So if you have random IPs, say 193.168.0.34 & 127.101.1.1.

You can use ^193.168.0.34$|^127.101.1.1$

Check the image below.

Google Analytics View Filter Exclude Random IPs
  • Save

As we discussed earlier ‘^’ denotes ‘starts with’, ‘$’ denotes ‘ends with’ & ‘|’ denotes ‘OR’ condition.

So, if you have five random IPs, you can simply put it in this format:

^IP1$|^IP2$|^IP3$|^IP4$|^IP5$

Click Save.

 

Tip #1: Use Regex Tool To Verify The Syntax

Sadly, Google Analytics does not provide the ‘preview‘ for IP address filters.

Google Analytics Preview Not Available
  • Save

No worries.

You can use any Regex testing tool available online. One of them, which I use a lot, is Regextester.

You can input your Regex pattern in the above row and paste all the IPs you want to exclude in the ‘Test String’ box.

I have included four IPs in the Regex pattern and pasted the same in the Test String box (along with one extra IP).

Google Analytics IP Filter Verify Syntax
  • Save

If the IPs turn blue, those are matched.

If everything goes well, you can copy the same expressions and add ^ & $ at the start/end of each IP and use it in Google Analytics.

Tip #2: Use Tag Assistant To Test Different IPs

Tag assistant is a chrome add-on which allows you to debug and test whether or not your Google tags are firing correctly.

One of the features is to change the IP address.

Tag Assistant Change Location
  • Save

You can test the IP addresses which you have excluded via Regex filters one by one and click ‘update’.

Tag assistant will re-analyze the reports and show you if the hits are well filtered. You can learn more about it here.

Final Thoughts

Google Analytics filters are non-retroactive. i.e., the filters will only alter the data moving forward.

So make sure you exclude internal IPs at the initial stages of setting up the Google Analytics.

This is a guest post by Ritwik. If you would like to submit something original for ShoutMeLoud then read our submission guidelines here.

Also, here are a few hand-picked guide for you to read next:

 

Was this helpful?

Thanks for your feedback!
  • Save
29Shares
Authored By
Ritwik is Web Analyst & Growth Hacking consultant. He runs a blog named Digishuffle where he writes about Web/Google Analytics, Tag Manager, Scripts & more. He is also the founder of Digixport- A Reporting Addon for Agencies & SMBs which helps save your reporting time.

10 thoughts on “How To Use Google Analytics View Filters To Exclude Multiple IPs”

  1. Arsie Organo Jr

    On some cases I will disagree with this approach. Why? Let’s say you are in an office and no one knows you blog. And then this colleague of yours tried to search for something without you knowing. It happens that your site have that information. For me it is an organic traffic and with your approach, this will deduct that single visitor from being counted. I know companies with more than a hundred of employees in one building. And you are going to let go of those number of visitors coming to your site?

    A better approach is if you, let’s say working on WP and previewing your post or drafts then you can use regex to and exclude the preview patterns. Or if you are assigned with static IP, then add your own IP address. I would not recommend putting the whole subnet.

  2. David Brian

    I will help me to get the good results. Is it necessary to exclude our IP address for all of our websites? so I with my team work on those strategies to achieve our goals. Thanks for sharing the helpful strategies.

  3. Swapana

    Hi Ritwik,
    Awesome article share. I am using Google Analytics from last 3 year. It really helps me to understand my website report and filter my audience.
    In this live traffic analysis field, it is the best service which Google provides for free.

  4. Shefali

    Thankyou for sharing this! It’s very important at times, you can do that for people at your office who are active on your website to filter them and get the actual results ( target traffic). I will definitely try this!

  5. Deepak Sharma

    Hey Ritwik
    Very informative article
    Keep writing

  6. Seema

    Wow! such a nice article. Earlier I tried to filter my IPs in google analytics but I failed each and every time. I also googled it but didn’t get the proper method. This article is really awesome, now I have successfully blocked my own IPs from google analytics.

  7. Steph | BuriedUnderWeight.com

    Hi there. I really enjoyed reading this article by Ritwik. It was extremely detailed and helpful.

    Usually when I’m creating posts for the lifestyle blog, BuriedUnderWeight, I do a lot of previewing prior to publishing. It was hard for me to understand how to filter my IP address after reading the Google help pages. It was very techie for my eyes.

    The frustration of having to estimate your traffic because you don’t know how to filter IP addresses properly, is heavy. And I hadn’t found an article that really dived into the HOW of it. But now I have.

    This post, while providing technical knowledge, is written for everyone to understand. Plus, you give options on how to filter. That is so appreciated.

    I’d given up on trying to filter my IP addresses and went with estimates. Now that I’ve gained the helpful information here, I can set up my GA for filtering.

    Thank you so much!

  8. Mary Ethan

    It means I was doing it wrong since I started building sites. I usually visit my sites many times to preview the content before publishing or making any type of changes to my website. But I think it will be a great idea that I can exclude my IP. What if we don’t have static IP?

  9. Scott Fainstein

    Hi Ritwik,

    Good article! I’m currently testing out GA’s IP anonymizing solution which obfuscates the last octet returning only 0. So, 168.1.10.0/255 will all show up as 168.1.10.0. However, when filtering out our internal IPs to not skew our client’s website data, we are now faced with loosing a lot of data. This anonymization is in response to GDPR conformity. Apparently, GA will first anonymize the IP and then process the data. However, Adobe Analytics will first process the data and then obfuscate the IP which is the best of both worlds as nothing valuable is lost and visitors get to keep their privacy. Anyhow, pardon the long rant. I was wondering if you’ve encountered this scenario and if you’ve come up with any solutions to not loose bulk IP data when filtering internal IPs out?

    Hope this message finds you well and thank you,

    Scott Fainstein

  10. The Urban Indian

    This is so helpful. I have always felt that analytics stats were not always accurate since i was checking my blog myself as well. This will definitely help me in the long run. Thanks again for such an informative article

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top