Filtering the internal website visits from you and your team from Google Analytics will keep your data cleaner, and will prevent your sessions from diluting your conversion/engagement metrics. This will provide a more accurate representation of your website’s actual performance and will improve the overall analysis.
Quick Links:
How To Filter Your IP From Google Analytics
IP Filters can be applied in the Filter Settings of the View in your Google Analytics Account. You can use a pre-defined filter type to Exclude traffic from the IP Address that equals your IP Address. Moving forward, traffic from that IP Address will be filtered out.
Keep reading for more detailed instructions and specific use cases, such as filtering multiple IPs and IP Ranges.
What If My IP Doesn’t Look Like That? (IPv4 & IPv6 Filters)
An IPv4 Address looks like 68.123.45.76
An IPv6 Address looks like 2604:2100:f1c4:6a00:6407:f333:5cd6:eeff
To filter an IPv6 Address in Google Analytics, you can use the exact same instructions for filtering a single IP above. The multiple IP instructions lower on this page will also work.
Don’t combine both address types in the same filter, as the filters should contain only IPv4 or only IPv6 addresses. Break them out into 2 or more filters.
How Can I Verify My IP Filter Is Working?
With most filters, you can click the “verify filter” link at the bottom of the filter editor. This will let you know how data from the last 7 days would have been impacted had the filter been applied. However, the IP Filters don’t offer this function, and there isn’t a clean way to test the IP Filter is working immediately.
The best way to verify your IP filter is working is to add the filter and then check the data after a few days. If you’re able to identify yourself based on your location or certain actions taken on the site, you should see that traffic stop.
The Real-Time Reports are not a reliable way to test IP Filters. You may show up in those reports, even though your interactions will later be filled out in the main reports.
Setting Up Filters For Multiple IP Addresses
Setting up a different filter for each IP address is the most straight forward way to filter out multiple IPs. While this easily works for 2-3 IPs, it quickly becomes unmanageable with the more IPs added.
To filter out multiple IP addresses in a single filter, regular expressions can be leveraged. This can allow you to quickly filter out a list of unique IPs, or filter out entire ranges of IPs. Follow the steps below to start filtering out your list of IPs.
Quick Introduction To RegEx To Filter Multiple IPs
Regular Expressions, or RegEx for short, are used as a way of matching different items. If I wanted to create a filter to match IP1 and IP2, I would enter “IP1|IP2” – with the vertical bar “|” in between. This bar means “OR” so my RegEx phrase means “Match IP1 OR IP2,” which is exactly the goal of the filter.
To combine multiple IPs, just put the vertical bar between them: 123.456.78|910.234.12
The period in RegEx means “any character,” which means the periods found in IP addresses could technically match something other than our IPs. To stick with best practices and to ensure only the intended IPs are matched, we can use a “\” to make the period only match periods.
The proper way to write an IP in RegEx is 123\.456\.78
The above example with combined IPs would look like 123\.456\.78|910\.234\.12
I highly recommend learning more about RegEx here – https://regexone.com/
How To Filter Out Ranges Of IPs
Using more advanced RegEx, you can block entire ranges of IPs. It’s common at larger companies to have their network across a range of IPs, where the first portion of the IP is the same and only the last few digits change.
An example range 68.123.45. [0-255], meaning they have 256 IP Addresses that all start with 68.123.45
In this case, you have a few potential options:
- Use a Predefined Filter for IP Addresses that contain 68.123.45
- Use a Custom Filter for IP Addresses and use the RegEx 68\.123\.45\.
- Use the Custom Filter RegEx ^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$
- Example from: https://www.regular-expressions.info/numericranges.html
As you can see RegEx can become very complicated, very quickly. I recommend taking the free RegEx course at https://regexone.com/, and then checking all of your RegEx using https://regex101.com/. This site will let you paste in a list of IPs and test your RegEx against the list – so you can ensure everything is matched.
IP Filter FAQs
What’s Next?
I hope you learned everything you wanted to know about IP filters in Google Analytics! Reach out in the comments below if you have any questions, find any errors, or want me to expand on anything. Thank you!