Sub topic 2
Turning On Debug Mode and Reading DebugView
This chapter assumes you have Editor access to a GA4 property, a web or app data stream, and access to the site code, the app project, or a Google Tag Manager container. You should already know what GA4 events, event parameters, and user properties are.
Debug mode marks events from one device so GA4 shows them in DebugView, a near-real-time event stream. Unflagged events still reach standard reports, but those reports process data over hours, so they are too slow for checking a change.
Turning on debug mode for a website
Add debug_mode to your config call. Every event sent during that page load is then flagged as debug traffic.
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', { 'debug_mode': true });
</script>Google Tag Manager preview mode and Tag Assistant also set debug mode for the browser session, so you do not need to edit the page.
Turning on debug mode in Android and iOS apps
- Android: Connect a device with USB debugging on, then run the following from a terminal. The first command enables debug mode for the package. The second disables it.
# Enable debug mode for the app
adb shell setprop debug.firebase.analytics.app com.example.myapp
# Disable debug mode
adb shell setprop debug.firebase.analytics.app .none.- iOS: In Xcode, open Product, then Scheme, then Edit Scheme. Under Run, Arguments, add the launch argument
-FIRDebugEnabled. Remove it to turn debug mode off.
Opening DebugView
Open DebugView from the Configure section of the GA4 navigation. The device selector at the top lists every device sending debug events. Choose the device you just used. The timeline is divided by minute and second, so you can match each event to the action you performed.
Inspecting events, parameters and user properties in DebugView
Each row in the timeline is one event. Click a row to see its parameters and user properties. Check the spelling of each name. GA4 does not reject a misspelled parameter. It records the value under the new name, so the error appears only as an unexpected column in your reports.
Exercise
You added debug_mode to the config call, but DebugView shows no device. What do you check first?
Show answer
Confirm that the page loads the gtag script and runs the config call in the browser console. Then confirm that the measurement ID matches the data stream of the property you are viewing. Finally, check that no ad blocker or browser setting blocks the analytics request.