An essential part of using Google Analytics is to filter out traffic that skews your data. There are several types of traffic you may want to filter. The most obvious one is your own. This includes from your home, your office, and anywhere else you hit your site. It may also include your co-workers, unless one of your target audiences is your co-workers.
Filtering a single IP address is easy and takes just a matter of minutes to set up, if that. However filtering a range of IP addresses may be a bit more challenging, but is definitely doable.
1. To begin, log in to Google Analytics at https://www.google.com/analytics/settings/home
2. Click Admin at the top right of the page.
3. Select the account for which you want to create the filter.
4. Click the Filters tab.
5. Click + New Filter.
6. Enter a name for the filter. If you’re adding several filters that relate to each other, such as your home IP address and work IP address, get the filters a name that distinguishes them.
7. Select Predefined filter to select from the predefined filter types. From there your filter can exclude or include only certain traffic based on ISP, IP, requested subdirectories, or requested hostname. If you’d like to make a more advanced filter, such as to filter a range of IP addresses, skip this step.
8. To make an advanced filter, such as to filter an IP address range, select Custom filter.
9. Select Visitor IP Address in Filter Field.
10. In Filter Pattern enter the IP address as a regular expression. Regular expressions are special characters that match the data and perform an action when a match is achieved.
- If the single IP address is 22.214.171.124, then enter 126.96.36.199
- If the range of IP addresses is from 188.8.131.52 to 184.108.40.206. Enter 3.12.71.[1-9]
- Here’s an even more complex example. You may need to brush up on your regular expression skills to accomplish this. If the IP addresses range is 220.127.116.11-25 and 10.0.0.1-14, then enter ^176.168.1.([1-9]|1[0-9]|2[0-5])$|^10.0.0.([1-9]|1[0-4])$
11. From the Available profiles list, select the profiles to which you want to apply the filter, then click Add, and lastly Save changes.
Congratulations! You’re now filter an IP address range. One way to test your filter is to browse to a private page that no one else would have access to, and see if any traffic to that page gets recorded in your Google Analytics account.
4 responses to “How to filter an IP address range in Google Analytics”
Thanks..I always forget how to do this; I get a new laptop and have to search again.
You’re welcome, Elsie. Thanks for stopping by!
The only thing this post is missing is the following link: http://www.analyticsmarket.com/freetools/ipregex
Just coming back to this, as I found a nice ‘n’ shiny tool to accomplish IP Address filtering well. ipaddressregex.com will easily add those . front-slash dots for you.
I use this on a daily basis as a best practice for client work (so I make use of Google’s Demo Account example of Test View), and if I want to include/exclude multiple IP Addresses, I just add the vertical pipe character | in between escaped IP Addresses.