Sub topic 6
Turning on debug mode for a website
Assume you already understand GA4 events and parameters, have a web data stream, and can access either the site code, Google Tag Manager, or Tag Assistant. Debug mode marks selected website events as test traffic so GA4 can display them in DebugView.
Debug mode does not create different event names. It adds a debug flag to events that your browser sends. You can then inspect the event, its parameters, and the user properties associated with the test device.
Use gtag.js
If your site sends data with the Google tag, add debug_mode: true to the configuration command:
gtag('config', 'G-XXXXXXXXXX', {
debug_mode: true
});This marks events from that page load as debug traffic. Replace G-XXXXXXXXXX with your web stream's measurement ID.
You can also mark one event instead of the entire page load:
gtag('event', 'sign_up', {
method: 'email',
debug_mode: true
});Event-level debugging is useful when you want to test one interaction without marking every event from the page. Keep the setting out of normal production traffic unless you intentionally want those users treated as developer traffic.
Use Google Tag Manager
Google Tag Manager (GTM) preview mode connects your browser to a draft container. It also marks analytics requests from that preview session for debugging.
- Open the container in Google Tag Manager.
- Select Preview.
- Enter the website URL and connect.
- Perform the action you want to test, such as submitting a sign-up form.
- In the Tag Assistant window, confirm that the Google tag and GA4 event tag fired.
- Open GA4 Admin, then DebugView, and select the test device.
Check both tools. GTM tells you whether a tag fired and what values it used. DebugView tells you whether GA4 received the resulting event.
Use Tag Assistant
Tag Assistant can connect to a site and enable debug collection for the connected browser session. Open Tag Assistant, start a connection to your website, and complete the interaction you want to test. Then inspect the corresponding device in DebugView.
The connection must remain active while you generate events. If you open a different browser, use an unrelated tab, or remove the connection, that activity might not carry the debug flag.
| Method | Scope | Best use |
|---|---|---|
| `gtag.js` `debug_mode` | Page or individual event | Code-controlled testing |
| GTM Preview | Preview browser session | Checking tag triggers and variables |
| Tag Assistant | Connected browser session | Quick website verification |
How the browser-to-DebugView path works
After enabling debugging, open DebugView in the correct GA4 property. Generate a fresh event from the connected browser. Select the device that becomes active, then inspect the event name and parameter values.
Exercise
Exercise
You need to test only a purchase event on a page that uses gtag.js. Which debug approach limits unrelated traffic?
Show answer
Add debug_mode: true to the purchase event parameters instead of adding it to the global config command.