Sub topic 8
Excluding developer traffic with debug_mode
This chapter covers the developer traffic data filter and the debug_mode parameter that drives it. It assumes you have a GA4 property with a web data stream, Editor or Administrator access, and a working knowledge of events, parameters, and the gtag.js configuration call. It also assumes you have read the earlier chapters on internal traffic rules and data filter states.
Why developers need a separate exclusion
An internal traffic rule works well for staff who sit on a known network. Developers are a different case. They test from home, from coffee shops, over VPNs, and on phones that switch networks. They also fire many unusual events while they build and debug a tracking setup: duplicate purchases, test form submissions, and events with placeholder values.
GA4 handles this with a second mechanism, the developer traffic filter. It does not look at IP addresses. It looks at whether an event was sent in debug mode.
What debug_mode does
debug_mode is an event parameter that tells GA4 to show an event in DebugView. DebugView is the report under Admin, in the Data display section, that streams events from a single device in near real time. It is meant for checking that your tags send the right events with the right parameters.
You can turn debug mode on in the configuration call:
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});With this call, every event sent from that page load carries the debug_mode parameter. Those events appear in DebugView. They are also the events that the developer traffic filter excludes when it is active.
You can also set it on a single event:
gtag('event', 'sign_up', {
'method': 'email',
'debug_mode': true
});Setting it on one event is useful when you want to test one interaction without marking the whole page load.
Other ways debug mode gets switched on
You do not have to edit code to produce debug events. These methods also work:
- The Google Analytics Debugger Chrome extension turns on debug mode for every page you load in that browser.
- Google Tag Manager preview mode sends debug events from GA4 tags while you are previewing a container.
- The Measurement Protocol accepts a
debug_modeparameter in the event payload, which is useful for server-side tests.
Because of this, a developer who uses any of these tools is already covered by the developer traffic filter, with no network configuration at all.
How the developer traffic filter works
The developer traffic filter is one of the data filter types at the property level. You find it under Admin, then Data collection and modification, then Data filters. GA4 creates a filter of this type for you. You do not define a rule for it, and you cannot change what it matches. You can only change its state.
The filter acts on events that have debug_mode set to true. When the filter is active, GA4 drops those events during processing. They never reach your reports, explorations, BigQuery export, or audiences.
The following diagram shows where the decision happens.
Filter states apply here too
The three states behave as they do for the internal traffic filter:
| State | Effect on debug events | Visible in reports |
|---|---|---|
| Testing | Events are kept and labeled with the filter name | Yes, and you can see which would be excluded |
| Active | Events are permanently excluded | No |
| Inactive | The filter does nothing | Yes, with no label |
The Active state is not reversible for past data. Events excluded while the filter was active are gone. Switching the filter to Inactive later does not bring them back, and it only stops further exclusion. Plan for this before you activate.
Testing the filter before you activate it
Use the Testing state to confirm that the filter matches what you expect.
- Open Admin, then Data collection and modification, then Data filters.
- Find the Developer traffic filter and set its state to Testing.
- Send events with
debug_modeset to true from a test device. - Open Explore, or a report where you can add secondary dimensions, and add the dimension Test data filter name.
- Look for events labeled with the developer traffic filter name.
Events with a label are the ones that would be excluded once the filter is active. Events without a label are unaffected. Give the data a day to process before you judge the result, because standard reports can lag behind DebugView.
A common mistake: expecting DebugView to hide the events
DebugView keeps showing debug events when the filter is active. DebugView is a separate stream that reads events before they are filtered out of reports. If you activate the filter and still see events in DebugView, the filter is not broken. Check the standard reports or an exploration instead. The events should be missing there.
Combining the developer filter with internal traffic rules
The two filters are independent. An event is excluded if it matches either filter while that filter is active.
- An event from an office IP address with no
debug_modeis excluded by the internal traffic filter only. - An event from a home connection with
debug_modetrue is excluded by the developer traffic filter only. - An event from the office with
debug_modetrue matches both.
If you also set traffic_type by hand on the configuration call, you can combine it with debug mode:
gtag('config', 'G-XXXXXXXXXX', {
'traffic_type': 'internal',
'debug_mode': true
});Here the traffic_type value feeds the internal traffic filter and the debug_mode value feeds the developer filter. Using both is rarely necessary, but it makes sense on a staging site where you want to see events in DebugView and also keep them out of production data.
Gotchas and failure modes
Debug mode left on in production
If someone ships 'debug_mode': true in the production tag, every real visitor is treated as developer traffic. With the filter active, all of your data disappears from reports, and the loss is permanent. Check for this in code review. A reliable pattern is to set the flag only from an environment variable or a hostname check:
var isStaging = window.location.hostname === 'staging.example.com';
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': isStaging
});Passing false is safe. GA4 treats an event as debug traffic only when the value is true.
The Chrome extension stays on
Developers sometimes leave the Google Analytics Debugger extension enabled and later browse the live site as a normal visitor to check something. Those visits are excluded from reports. That is usually what you want, but it can surprise someone who is trying to confirm that a real session appears in reports. Turn the extension off for that check.
Debug events and other data
When the developer filter is in the Testing or Inactive state, debug events count in all reports. Conversions, user counts, and revenue will include test purchases. If your property has been collecting debug events for months with the filter inactive, expect inflated numbers in that period. A new filter does not correct earlier data.
BigQuery
The filter applies before export, so excluded events are absent from BigQuery. Events in the Testing state are exported, and the filter label is not a column you can rely on there. Treat Testing as a reporting-interface check only.
Audit steps for developer traffic
- Confirm that the developer traffic filter exists and note its state.
- Search the production code and any Tag Manager containers for
debug_mode, and confirm it is only set conditionally. - Ask developers which tools they use, and make sure the filter state matches your policy.
- If the filter is inactive, look at past data for suspicious events, such as test purchases, using an exploration filtered by event name and time.
- Document the date the filter became active, so that analysts know why data changed.
Summary of key points
debug_modemarks events for DebugView and is the signal the developer traffic filter uses.- The filter has no rule to edit. You only choose Testing, Active, or Inactive.
- It works without IP addresses, so it covers developers on any network.
- Excluded events are lost permanently, and DebugView still shows them.
- A stray
debug_mode: truein production hides real traffic once the filter is active.
Exercise
You activate the developer traffic filter. A colleague says the filter is not working because their test events still show up in DebugView. Is the filter broken? How would you check, and what is one risk you should confirm is absent from the production site?
Show answer
The filter is not necessarily broken. DebugView reads events before report-level filtering, so debug events remain visible there even when the filter is active. To check, look at a standard report or an Explore exploration for the test event after processing time, and confirm that it is missing. The risk to rule out is a production tag that sets debug_mode to true, because with the filter active it would permanently exclude real visitors' events.
Exercise
A developer works from home on a changing IP address and uses Google Tag Manager preview mode. Which filter excludes their events, the internal traffic filter or the developer traffic filter, and why?
Show answer
The developer traffic filter. Tag Manager preview mode sends GA4 events with debugmode set to true, and the developer filter matches on that parameter, not on IP address. The internal traffic filter would miss this developer because their IP address is not in any defined rule and traffictype is not set.