Filter traffic in Google Analytics

You and your development team will probably be visiting your own site - a lot. Testing sales funnels, contact forms and newsletter sign-ups. Those actions should not end up in your Google Analytics profile: it will mess up your numbers and give you a wrong impression of how your site is doing.

There's an easy way to fix this: filter out your own traffic based on your IP address!

Step 1. Identify Internal Traffic in Google Analytics 4

  • Visit the Admin page in GA4.
  • Navigate to Data collection and modification.
  • Click on Data streams.
  • Select a web data stream and then click Configure tag settings.
  • Select Define internal traffic.
  • Now, click Create to start creating a new rule for recognizing internal traffic in GA4. 
  • You'll see the traffic_type parameter, which is the only one you should add value. Typically, GA4 will call it "internal" by default, but if you want to separate different internal traffic sources (e.g., development team vs marketing team), you can do so at this point.
  • Navigate to IP address, select Match type, and enter the internal IP addresses in Value
  • Don't know what your IP address is? Go to whatsmyip.org.

Step 2. Set up a Data Filter in GA4

  • Visit the Admin page in GA4.
  • Navigate to Data collection and modification.
  • Select Data filters.
  • Select Internal traffic
  • Enter a name for the filter.
  • Then, select Exclude and choose which traffic_type parameters you want to exclude. The value should match the name you entered in the previous step.
  • Choose the filter state - If GA4 identifies matching data with the "Test data filter name" dimension, it'll be excluded with the Testing state. Choose Active if you want GA4 to apply the data filter to incoming data and makes permanent changes. If you don't want Analytics to evaluate the filter, choose the Inactive option.

How to Test GA4 Traffic Filtering

Once you've set everything up, make sure that it works! Create a Free form exploration in GA4 using the following settings:

  • Rows: Test data filter name, Event name
  • Values: Event count
  • Filter: "Test data filter name contains [the name of your filter]"


The data filter should be applied within 36 hours. If you've done everything correctly, the traffic from those IP addresses won't show up in the reports anymore!

Pro tip: Always create a raw data view that doesn't have any filters. This will serve as a backup. If you accidentally filter out too much data, there's no way to get that data back in by removing the filter. The Raw Data view will still have that missing data.

Different Properties for Test Sites Using Google Tag Manager

If you have a development, testing, or staging environment where your product is being tested, create a separate Analytics property for those environments. That will not only keep your testing activity out of your live Analytics profile - it will also let you test your Analytics settings.

Here's a quick way to use a different Google Analytics Property for your test environment  if you're using Google Tag Manager:

Create a new custom variable called Google Analytics Tracking Code, of type Lookup Table. We'll use this variable to set the tracking code based on the URL of the website.

Lookup table with local, testing and live hostnames in Tag Manager

Next, go to the Google Analytics Settings variable, and select the Google Analytics Tracking Code variable you just created:

Variable Google Analytics Tracking code

You can also modify your Google Analytics 4 tags to be sure. Open the tag and replace it with the lookup table. 

And that's all! No longer will your live Analytics profile be ruined by testing data and your own traffic!