Filtering an IP in Google Analytics is pretty simple (see post). But in many cases, a company will have multiple IPs to exclude, e.g. multiple office locations.
In this post I’ll cover several ways to implement such filters.
One way of applying such filters is by adding a single filter for each IP. Following the instructions on my previous post, you can easily set up an IP filter and add as many as you like for each office location.
Google Analytics filters apply in the order in which they are set, so the final input will have passed through all filter.
Another option, when wanting to exclude multiple IP addresses in one shot, is creating one filter that captures multiple addresses.
To achieve that, you need to create a filter of the type ‘Custom’. Select Exclude and use the Filter Field ‘IP Address’.
The Filter Pattern uses regular expression matching, so you can input multiple IP addresses separated by a pipeline | to exclude multiple IPs using one filter.
Following the solution above, in some cases the offices might use a range of IP addresses and not only one single address. This is very common for larger offices and campuses.
In this case, you can use the regular expression matching to exclude an entire range of IPs.
The most common case is excluding an IP C-Class. This is the entire range of IPs indicated by the final digits in the IP address. For example, 234 in the address below.
To exclude the entire range, we can create a filter to match 123.123.123.*
This will exclude all traffic that matches this pattern, e.g. 22.214.171.124
This is a simplified version of the regular expression syntax that could include edge cases. The “full” syntax should actually be 123\.123\.123\..*
Leave a Reply