Analytics
2.4K members online now
2.4K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

Excluding multiple IP ranges with regular expression

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I set up the Google Analytics environment for a client of mine with multiple offices. I created two views: one with the raw data, another that should filter out all internal traffic of the offices.

 

The client delivered me a number of IP ranges to excluded from the view, such as the following:

10.151.6.0 – 254

 

I used a regex tool to create the following regular expression.

^10\.151\.6\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))$

 

I entered this regex as a custom IP address to exclude, but it doesn't seem to be working. The raw view and filtered view still display the same session count.


What am I overlooking here?

2 Expert replyverified_user

Re: Excluding multiple IP ranges with regular expression

[ Edited ]
Rising Star
# 2
Rising Star

Hi Laurens,

Your expression looks good and should be working if the filter is configured correctly
https://regex101.com/r/kX0cZ3/1

A few things to consider:
- Filters will only work for future hits.
- It may take up to 24hrs for the filters to start working
- Check if the filter is not applied to both properties.

Hope it helps,

Google Analytics Rising Star | Was my response helpful? If yes, please mark it as the 'Best Answer.' Learn how here!
Analytics Consultant at Carloseo.com - Find me on Twitter | Email me
Marked as Best Answer.
Solution
Accepted by topic author Laurens B
August 2016

Re: Excluding multiple IP ranges with regular expression

[ Edited ]
Top Contributor
# 3
Top Contributor

You're actually better off with this:

^10\.151\.6\..*

VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

Re: Excluding multiple IP ranges with regular expression

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Thank you! I have implemented this regex and I hope it works now.

I understand that the ..* indicates a full range of numbers (being 0 to 254). What happens if it is a selected range? For instance 192 - 254? Would \.(1(9[2-9])|2([0-4][0-9]|5[0-4]))$ be correct then?

Really appreciate the help!

Laurens