Sub topic 7
Verifying a filter before you activate it
This chapter covers how to prove that an internal traffic filter matches the right traffic before it deletes anything. It assumes you can already do these things:
- Define an internal traffic rule in the web data stream's tag settings.
- Create a data filter at the property level.
- Open Explorations and DebugView.
If you haven't done them, review the earlier chapters on internal traffic rules and data filters first.
Why verification matters
An active data filter is destructive. Once the filter is Active, GA4 drops matching events during processing. You can't get those events back, and changing the filter later doesn't restore them. A rule with a typo in the IP range, or a rule that matches too much, can silently discard real customer traffic.
The Testing state exists to prevent this. It lets you see what the filter would exclude, while all data keeps flowing into your reports. You need three facts before you switch to Active:
- Your own visits carry the
traffic_typevalue you expect. - The filter's value matches that
traffic_typevalue exactly. - Real visitors do not match.
What Testing mode does
A filter in the Testing state does not remove any data. It tags each event it would have excluded with the filter's name. That tag is exposed as the Test data filter name dimension.
The dimension is not in the standard reports. You read it in an Exploration (Explore, then Free form) by adding it as a dimension. Standard reports show the data unfiltered, so internal traffic remains visible in them throughout testing.
The three states behave like this:
| State | Events removed from reports | Events tagged with Test data filter name | Reversible |
|---|---|---|---|
| Testing | No | Yes | Yes, fully |
| Active | Yes, permanently | No | Only going forward |
| Inactive | No | No | Yes |
Moving from Active to Inactive stops future exclusion. The events already dropped stay lost.
Step 1: Confirm the traffic_type value is being sent
The data filter works only on events that already carry the traffic_type parameter. The internal traffic rule adds that parameter. If the rule does not match your IP address, nothing is tagged, and the filter has nothing to act on.
Check this first, before you look at the filter:
- Open the site from the network you want to exclude.
- Open DebugView in the property's Admin area, under Data display.
- Click an event in the stream and expand its parameters.
- Look for
traffic_typewith the value from your rule, such asinternal.
DebugView only lists events from devices in debug mode. Turn debug mode on with the Google Analytics Debugger browser extension, or by setting the parameter in your tag:
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});If traffic_type is missing, the rule did not match. Fix the rule before going further. Common causes:
- Your public IP address is different from the one you entered. Look it up from the same network, not from a phone on mobile data.
- You entered a private address such as
192.168.1.10. GA4 only sees the public address of your connection. - The rule was saved after the page loaded. Reload the page, then test again.
- The stream has another tag configuration that overrides or removes the rule's effect.
A forced test when the IP rule is not ready
You can separate the two problems, rule matching and filter matching, by setting the parameter yourself on a test page:
gtag('config', 'G-XXXXXXXXXX', {
'traffic_type': 'internal'
});If the filter tags these events in Step 2, the filter is configured correctly and any remaining fault is in the IP rule. If the filter does not tag them, the problem is the filter's value, its state, or its timing.
Remove this snippet from the page after testing. Left in place, it tags every visitor as internal.
Step 2: Read the Test data filter name dimension
With the filter in Testing, generate some internal traffic. Visit several pages and trigger a few events from the excluded network. Then build an Exploration:
- In Explore, create a Free form exploration.
- Under Dimensions, import Test data filter name and Event name. Add Page path and screen class if you want to see which pages were visited.
- Under Metrics, import Event count.
- Drag Test data filter name into Rows, and Event count into Values.
You should see rows grouped by your filter's name, such as Internal Traffic, plus a row with no filter name. That unnamed row is the traffic the filter would keep. Interpret the result like this:
| What you see | What it means | Action |
|---|---|---|
| Your test events appear under the filter name | The filter works | Continue to Step 3 |
| All events appear unnamed | Nothing matched | Re-check DebugView for `traffic_type`, then check the filter's value |
| Far more events under the filter name than you generated | The rule is too broad | Narrow the IP match before activating |
| No data at all | Processing delay | Wait and check again |
Timing
The dimension does not populate in real time. Allow several hours after you create the filter, and up to a day or two in some cases. A filter created minutes ago will show nothing, and an empty Exploration at that point is not evidence of a fault. Only events collected after the filter was created can be tagged. Visits you made earlier will not appear.
Step 3: Test for false positives
Matching your own traffic is half the check. The more dangerous failure is matching visitors who are not yours. Look for these cases:
- Shared public IP addresses. A coworking space, a shared office building, a university, or a carrier-grade NAT can put customers behind the same public address as you.
- CIDR ranges that are too wide. A rule of
203.0.113.0/24covers 256 addresses. If your company owns only a handful, a narrower range such as/29is safer. - Regular expressions that match more than intended. An unescaped dot matches any character, and a missing anchor (
^and$) lets the pattern match inside a longer address. Compare the earlier pattern with an unanchored version:
^203\.0\.113\.([1-9]|[1-9][0-9]|1[0-9]{2})$This matches only addresses from 203.0.113.1 to 203.0.113.199. Without the anchors it would also match any address that merely contains such a string.
To check for false positives, filter the exploration to the rows under the filter name. Then break them down by Country, City, or Page path. If you expected five people in one office and the exploration shows visitors from several countries, the rule is catching outsiders.
Also compare volume. Take the daily event count under the filter name and compare it with what you know about your team's activity. A small team rarely produces thousands of events a day.
Step 4: Test the developer traffic filter
The developer traffic filter works differently. It acts on events sent with debug_mode, not on traffic_type. Events from devices with debug mode on are what this filter excludes once it is active.
You can test it the same way:
- Create the developer traffic filter in Testing.
- Send a few events with
debug_modeset totrue. - Look for the filter's name in the Test data filter name dimension.
Note that DebugView is a separate tool for inspecting events. It is not a report, and it is not governed by the filter's state. Use it to inspect events and the Exploration to see what the filter would do.
Step 5: Activate, then watch
When the checks pass:
- Open Admin, then Data filters, and select the filter.
- Change its state from Testing to Active and confirm.
- Save a note of the date and time, since the change is not retroactive.
After activation, check again over the next one or two days:
- The Test data filter name dimension stops showing new rows for that filter, because the events no longer reach reports.
- Event counts for the same period drop by roughly the amount you saw under the filter name.
- A real conversion event, such as a purchase from a known external test customer, still arrives.
If the numbers fall by far more than expected, set the filter to Inactive at once. This limits the damage, because data processed during the Active period is already gone.
A pre-activation checklist
Work through this list for every filter:
- DebugView shows
traffic_typewith the expected value on events from your network. - The filter's internal traffic value matches the rule's value exactly, including letter case.
- The Exploration shows the filter name on your test events.
- The rows under the filter name contain no unexpected countries, cities, or pages.
- The daily volume under the filter name is plausible.
- You have waited long enough for processing, then checked again.
- You have recorded who activated the filter, and when.
Common errors
- The value mismatch. The rule sets
traffic_typetointernal, but the filter looks forInternal. The comparison is exact, so the filter matches nothing. Copy the value rather than retyping it. - Testing the wrong thing. Looking in a standard report instead of an Exploration. Standard reports do not show the test dimension.
- Reading too early. An empty Exploration within the first hours proves nothing.
- Confusing DebugView with a filter result. Seeing an event in DebugView says nothing about whether a filter would exclude it.
Exercise
You create an internal traffic filter in Testing state, visit your site from the office, and open a standard Acquisition report an hour later. Your visits are still there, and you cannot find the filter name anywhere. Is the filter broken? What should you check, and where?
Show answer
Not necessarily. A Testing filter never removes data, so your visits stay in standard reports, and the Test data filter name dimension is not available in them. It appears in Explorations, and it can take several hours to populate. First confirm in DebugView that your events carry traffic_type with the rule's value. Then build a Free form exploration with Test data filter name and Event count, and check again after a delay. If the dimension stays empty after a day, compare the filter's value with the rule's value for an exact match.
Exercise
The Exploration shows 4,000 events a day under your filter's name, but your team of six produces about 300. Names a likely cause and two ways to confirm it.
Show answer
The IP rule is probably too broad, for example a wide CIDR range or an unanchored regular expression, or your office shares a public address with other organizations. Break the filtered rows down by Country, City, and Page path to see whether the visitors are outside your team. Also compare the rule's range with the addresses you actually own, and narrow it before activating the filter.