Sub topic 12
Keeping developer and test traffic out of your reports
This chapter assumes you can use the GA4 Admin area, know what events and parameters are, and have Editor access to a property. It covers how to stop your own testing from polluting reports once the Realtime report and DebugView have confirmed that tracking works.
Why test traffic is a reporting problem
Every test you run sends real events to the property. A developer who loads a page 40 times, fires sign_up while checking a form, and walks through checkout in a staging build adds sessions, conversions and revenue to the same reports your stakeholders read. On a small site this can distort conversion rates. On any site it makes numbers harder to trust.
GA4 handles this with data filters. Two filters matter here:
- The Developer traffic filter removes events that were flagged as debug traffic.
- The Internal traffic filter removes events that carry a
traffic_typeparameter you have defined, usually based on IP address.
They target different things. The developer filter catches traffic that is already in debug mode. The internal filter catches traffic from known places or people, whether or not debug mode is on.
The Developer traffic filter
You turn on debug mode to feed DebugView, as covered in the earlier chapters. The same flag is what the Developer traffic filter looks for. Events count as developer traffic when they come from any of these sources:
- A page where
debug_modeis set totrueingtag('config', ...)or on an individual event. - A Google Tag Manager container in preview mode.
- A session using Tag Assistant.
- An app device with Firebase Analytics debug mode enabled.
So debugging and filtering use one signal. If you debug correctly, you can exclude that traffic with a single filter.
Where to find it
Open Admin, then Data collection and modification, then Data filters. The property lists its filters, and the Developer traffic filter is usually present already. You need Editor access to change a filter's state.
The three filter states
Each data filter is in exactly one state.
| State | What happens to matching events | When to use it |
|---|---|---|
| Testing | Events stay in your reports. They are labeled with the filter name in the **Test data filter name** dimension. | Checking what a filter would remove before committing |
| Active | Events are excluded as they are processed. | Normal operation once you trust the filter |
| Inactive | The filter does nothing. | Filter turned off, for example when you need to see test data in standard reports |
Testing is the safe first step. You can see how much traffic a filter would catch without losing any data.
Verifying a filter in Testing state
Use this sequence to confirm the filter does what you expect before activating it.
- Set the Developer traffic filter to Testing.
- Open your site with
debug_modeon and trigger a few distinct events, for examplesign_upandpage_view. - Wait for processing. Standard reports lag behind Realtime, so allow time before concluding anything.
- In an Exploration, add the Test data filter name dimension and compare it with your event counts.
- Confirm that your test events are labeled with the filter name and your normal traffic is not.
- Set the filter to Active only when the labels match.
If your test events are not labeled, the flag is not reaching GA4. Go back to DebugView and check that the device appears there. A device that DebugView does not show is not sending the debug flag, so the filter has nothing to match.
The Internal traffic filter
The developer filter does not help when a colleague browses the site normally, without debug mode. For that case you define internal traffic and filter on it. This is a two-part setup, and both parts must be in place.
Part 1: define the traffic
- Open Admin, then Data streams, and select your web stream.
- Select Configure tag settings, then Show more, then Define internal traffic.
- Create a rule. Give it a rule name, set
traffic_typeto a value such asinternal, and add an IP address match type with the address or range to match, for example your office network.
GA4 then adds traffic_type=internal to events from matching addresses. IP rules describe network locations. They do not follow a person who works from home on a changing address. For that case, set the parameter yourself, as shown below.
Part 2: filter on the parameter
In Data filters, open the Internal Traffic filter and check that its parameter value matches the traffic_type value you used in the rule. The value must match exactly. If your rule sends internal and the filter expects office, nothing is excluded and no error is shown.
Setting the parameter in code
When IP rules do not fit, for example for a QA environment on a changing address or a staging site that shares the production stream, send the parameter directly.
gtag('config', 'G-XXXXXXXXXX', {
'traffic_type': 'internal'
});Use the same value your filter expects. You can combine this with debug_mode in one config call when the page is only ever used for testing:
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true,
'traffic_type': 'internal'
});For Measurement Protocol events, put traffic_type in the event params object. The same filter then applies to server-side test events.
Choosing between the two filters
| Question | Developer traffic | Internal traffic |
|---|---|---|
| What does it match? | Events flagged with debug mode | Events with a matching `traffic_type` value |
| Needs an IP rule? | No | Usually, unless you set the parameter in code |
| Catches a colleague browsing normally? | No | Yes, if their address is covered |
| Catches your own debugging session? | Yes | Only if the rule also covers your address |
In practice, run both. Developer traffic covers debugging sessions without any configuration beyond activating the filter. Internal traffic covers routine non-debug use from known locations.
Common failure modes
- Filter is Active but test data still appears. The events probably arrived before activation, or the flag is missing. Filters apply to data from the moment they are active.
- Testing state never shows a label. Either no matching events arrived, or the
traffic_typevalue in the filter differs from the one being sent. - A real user's data disappears. An IP range in an internal traffic rule is too broad, for example a shared network or a VPN exit used by customers. Review the rule before activating the filter.
- Staging shares the production stream. Filters help, but a separate data stream or property for staging is the cleaner design. A filter only hides the traffic. It does not separate the environments.
- You need the data again. Set the filter to Inactive for new traffic, or use a separate test property. Excluded history cannot be restored.
Exercise
A colleague tests the site every day from the office without using debug mode or Tag Assistant. You have activated the Developer traffic filter, but their sessions still appear in reports. What two things do you set up, and in which state should the new filter start?
Show answer
The Developer traffic filter only matches events flagged as debug traffic, so it ignores normal browsing. Define internal traffic for the office IP range on the web stream (Configure tag settings, Define internal traffic) so GA4 adds a traffic_type parameter such as internal. Then make sure the Internal Traffic data filter uses the same traffic_type value. Start the filter in Testing state, check the Test data filter name dimension to confirm the colleague's sessions are labeled, and then set it to Active.
Exercise
You set the Internal Traffic filter to Active last week. Today you realize the rule used the wrong IP range, and a customer network was excluded. Will setting the filter back to Inactive restore last week's data?
Show answer
No. Active filters exclude events during processing, and the excluded events are not stored. Setting the filter to Inactive only stops new exclusions. To avoid this, run the filter in Testing state first and review the labeled data before activating it.