How to Filter Multiple IP Addresses in Google Analytics

If you’re reading this, you can probably relate to this story: You check your Google Analytics and start celebrating wildly about the traffic your site is generating.

But then, an uneasy feeling starts creeping in.

You think: “How much of this traffic is internal, from my own business?”

This is a classic scenario that happens to businesses and website owners all the time.

Never fear, though! We’re going to explain everything you need to know about filtering out multiple IP addresses so you have the right data to work with.

Why Would I Need to Exclude IP Addresses in Google Analytics?

To get an accurate view of your website traffic, you may need to exclude certain IP addresses, such as those from internal users (i.e., users in your company who are visiting your site).

That’s because employee traffic can drastically skew your metrics, as employees don’t operate on your website in the same way consumers do. They may linger longer on certain pages and visit pages that others might not.

Depending on the number of internal visits and how long this goes on for, it could severely impact your reporting and even lead to making poor decisions in the future.

How to Exclude a Single IP Address

First, let’s clarify how to exclude a single IP address.

Once we’ve got that process down, we’ll use regular expressions to create a filter that excludes multiple IP addresses at once.

If you'd like to learn how to do it in GA4, we have a video covering all types of GA4 filters on our YouTube channel:

Note: Before beginning, you must know the IP address that you want to filter out. To find your IP address, you can simply use Google Search.

Here’s how to do it:

  1. Go to “Admin” in your Google Analytics account.
  2. Find the “View” column and click on “Filters.”
  3. Click “Add filter.”
  4. Name your filter. Make sure it’s a naming convention that you’ll understand later. In most cases, I’d recommend that you name it after the specific network or device that’s being filtered.
  5. Leave the Filter Type as “Predefined” then select “Exclude” and “Traffic from the IP Addresses. Then for the last field you can select “That are equal to”.
  6. Now click save and your filter has been created! Bob in accounting isn’t going to mess with your metrics anymore!

How to Filter Multiple IP Addresses

Filtering one IP address at a time can be tedious and while it’s possible to exclude multiple IP addresses simply by creating multiple filters it’s not optimal or efficient.

So instead, we can use regular expressions within Google Analytics to efficiently filter multiple IP addresses all at once.

Creating A Combined Filter with Regular Expressions

To create a combined filter, we’ll want to follow all of the same steps above but instead of selecting “Predefined” as our filter type we’ll be selecting “Custom”.

That will give us several new options to choose from and you should end up with something like this:

The biggest difference here is the use of regular expressions which allow us to combine multiple IP addresses or create rules that cover large ranges of IPs.

You can learn more about regular expressions from Google and Annie Cushing of Annielytics also has a great article that breaks everything down in plain English.

While you can do a lot more with regular expressions than just filter multiple IP addresses, we’re only going to focus on those applications for this article.

Use A Backslash Between Decimals in the IP Address

The decimal or period actually has an existing use as a regular expression so in order to tell Google that we want our decimals to act only as an actual decimal we need to precede them with a backslash.

As an example, this IP:

74.125.19.103

Will need to be written as followed when used within a regular expression:

74\.125\.19\.103

Each backslash tells Google that what follows are intended to be decimals and nothing else.

Use A Pipeline To Combine IP Addresses

We can use a pipeline ( | ) to combine multiple IP addresses on one line. Let’s say we want to filter the following IP addresses:

74.125.19.103 and 74.125.19.01

While we could create a separate filter for each IP, we could also use the pipeline to combine them. Here’s what we’d end up with:

74\.125\.19\.103|74\.125\.19\.01

Google Analytics expert Fred Pike points out that you have to be very careful to not put a pipe at the end of the regular expression. Doing that will effectively filter ALL traffic.

As you can imagine, making that mistake will lead to some confusing calls around the office since instead of keeping Bob in accounting’s visits under control you’ve effectively excluded the entire planet.

How To Filter A Range of IP Addresses

Let's say your office uses a range of IP addresses from 74.125.19.01 to 74.125.19.50.

Adding 50 IPs with a series of pipes is going to take forever.

So instead, we’ll use a regular expression to filter the range.

Use A “\d” To Represent A Range of Digits

We can use \d to represent a range of digits 0 to 9. We can then combine that with * to cover multiple digits.

We’d end up with something like this:

74\.125\.19\.\d*

So what exactly does that cover?

A lot.

Here’s what would be covered by this filter:

74.125.19.2

74.125.19.45

74.125.19.367

74.125.19.506

…and so on.

You get the idea.

How Many IP Addresses Do YOU Actually Have?

It’s easy enough to search for your own IP address and if you’ve got a large network then you probably already know your IP range.

But have you considered all the other IP addresses that you or your employees might use to access your website?

Mobile devices are often overlooked and if people are using their phones off company wifi then you’ll have a lot more IPs than you may have expected at first. So make sure that when you’re building your IP filters you’re taking this into consideration, too.

How to Test Your IP Filter

Once you’ve created your IP filter, it’s time to test it to make sure it’s working properly.

Simply go to “Real-time reports” in your Google Analytics account and look for traffic. If your filter is working correctly, there shouldn’t be any.

Just a heads up that it can take anywhere from a few minutes to 24 hours for your filters to start working, so if you’re confident that your filters are set up properly, give it some time to take effect.

Filtering IP Addresses in Google Analytics 4

In late 2020, Google rolled out their new platform, known as Google Analytics 4. While many people are still using the previous version, Universal Analytics, others have switched over to the new GA4 platform.

Creating IP address filters in GA4 is done differently. If you’re using GA4, follow the steps below to create your filter.

Define Your IP Address

Before you can set up a new filter in GA4, you’ll need to define your IP address by following these steps:

  1. Click on “Admin” and go to “Data streams.”
  2. Select your desired data stream.
  3. Click “More Tagging settings.”
  4. Click “Define internal traffic.”
  5. Click “Create” to create a new rule. Now give your filter a name and add your IP address that you’d like to exclude. You can update the traffic type but I’d suggest leaving the default value.
  6. Click “Create” again.

Create Your IP Filter

Now that you’ve defined your IP address, you can create your filter.

Follow these steps to set up your filter:

  1. Click “Admin” > “Data settings” > “Data filters.”
  2. Within “Data filters,” click on “Create filter.”
  3. Select “Internal traffic” and then name your filter. Select “Exclude” under “Filter operation.” Then, under “Filter events with the following parameter value,” enter the traffic_type value that you entered when you defined your IP address (“Internal”).
  4. Change your filter to “Active state.” and then click save.

What About Regular Expressions In GA4?

Unfortunately, there’s currently no support for regular expressions within the IP filter of GA4.

There’s also currently a limit of 10 filters in GA4 so excluding multiple IP address in GA4 is much more tedious.

However, GA4 is quickly evolving and I’d expect this problem to be addressed in the future.

Wrap-Up

To make sure you’re getting accurate metrics, it’s important to filter out internal traffic, which may involve setting up multiple filters or using a combined filter.

If you’ve made the switch over to GA4, you’ll need to do things slightly differently, but the process is still fairly straightforward.  Just follow the step-by-step instructions to filter internal traffic in Google Analytics 4.

Do you have questions about or tips for filtering IP addresses in Google Analytics?

Let us know what you think in the comments below.

Price Lock Alert: Save $1000 on Lifetime Access To Academy Insiders

00
Months
00
Days
00
Hours
00
Minutes
00
Seconds
Scroll to Top