Analytics
2.8K members online now
2.8K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Excluding IP address ranges with RegEx?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I would like to know how to exclude internal traffic with RegEx. In our case, we have 4 large ranges of IPs (like 167.145.0.0/16) . The resulting RegEx (500 characters) will exceed the 255 character limit. Any ideas highly appreciated. 

2 Expert replyverified_user

Re: Excluding IP address ranges with RegEx?

Top Contributor
# 2
Top Contributor

Hi Marco,

 

You can create multiple exclude filters and use a single pattern in each. The regex for your IP above is 240 characters:

^167\.145\.(0\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|(([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|255\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Excluding IP address ranges with RegEx?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
HI Arnold,
thanks, but if we have 4 of them
167.148.0.0/16
170.168.0.0/16
162.141.0.0/16
146.209.0.0/16
there will probably no way to stay within the 255 character limit, correct?

Re: Excluding IP address ranges with RegEx?

Top Contributor
# 4
Top Contributor

Hi Marco,

 

Create four different exclude filters and add one pattern to each;

^167\.148\.(0\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|(([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|255\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$
^170\.168\.(0\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|(([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|255\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$
^162\.141\.(0\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|(([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|255\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$
^146\.209\.(0\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|(([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|255\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$

Let me know if this works for you.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Excluding IP address ranges with RegEx?

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
but how can I aggregate them, to have just one view with a filter in the end?

Re: Excluding IP address ranges with RegEx?

[ Edited ]
Top Contributor
# 6
Top Contributor

Hi Marco P,

@Arnold M's filters can be applied to the same view and will function the same way as your original aggregated filter. GA applies the filters top-down, so it goes through your first view filter, sees if it applies, and then moves down one by one.

Nicky Yuen, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.
Find me on: Google+ | LinkedIn

Re: Excluding IP address ranges with RegEx?

Top Contributor
# 7
Top Contributor
Just apply the four separate filters to the same view.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital