Sub topic 5
Debug mode: how events are flagged for DebugView
Assume you understand GA4 events, event parameters, data streams, and basic access to the GA4 Admin area. This chapter explains how debug mode marks test events so DebugView can display them.
What debug mode does
GA4 normally processes events as production data. Debug mode adds a signal that identifies an event as being generated during implementation testing. DebugView uses this signal to show the event quickly for an individual test device.
The signal is the debug_mode parameter. Set it to true on an event, or set it in the Google tag configuration to mark events from that page load.
gtag('config', 'G-XXXXXXXXXX', {
'debug_mode': true
});
gtag('event', 'sign_up', {
'method': 'email',
'debug_mode': true
});The first call flags events sent through that page's Google tag configuration. The second call flags only the sign_up event. Use event-level debug mode when you want to test one interaction without marking every event from the page.
The value must be a Boolean true, not the text "true".
How an event reaches DebugView
Debug mode does not change the event name or its parameters. It changes how GA4 identifies the traffic for debugging. You still need to verify that the event name, parameter names, parameter values, and user properties are correct.
Web and app implementations
For a website, you can enable debug mode in several ways:
- Add
debug_mode: trueto thegtag.jsconfiguration or to a specific event. - Use Google Tag Manager preview mode while testing tags.
- Use Tag Assistant to connect to the site and inspect tag execution.
These methods are intended for the browser session you are testing. Test in a clean browser session when cookies, consent settings, or multiple analytics tags could make results confusing.
For an Android app using Firebase Analytics, enable debug mode for the package on a connected test device:
adb shell setprop debug.firebase.analytics.app com.example.myappTurn it off after testing:
adb shell setprop debug.firebase.analytics.app .none.For iOS, launch the app with the Firebase Analytics argument -FIRDebugEnabled. Disable it with -FIRDebugDisabled. Configure the argument in the Xcode scheme used for testing, not in the production release configuration.
What debug mode does not guarantee
A debug flag does not repair an incorrectly implemented event. DebugView can show an event with a misspelled name or missing parameter because it reports what GA4 received. It also cannot show an event that never left the browser or app.
Debug mode may coexist with network delays, consent restrictions, ad blockers, offline mobile events, or an incorrect measurement ID. After enabling it, open DebugView and select the device that generated the test traffic.
Exercise
You need to test only the purchase event on a web page. Should you set debug_mode in the global configuration or on the event?
Show answer
Set debug_mode: true on the purchase event so other events from the page are not marked as debug traffic.