Steve Fenton

How to debug Google Analytics v4 (GA4)

Sometimes you need to see what’s going on under the hood of your analytics tracking. Google Analytics v4 (GA4) provides a simple way to debug your configuration either at the property level, or per-event.

The DebugView screen

The DebugView can be found in your Google Analytics v4 property, at the bottom of the menu.

Google Analytics v4 Debug View

One of the useful features is that when you choose an event, it will show you the value over time. For example, in the screenshot below the ConsentLoaded event shows the value for “HasIndicatedConsent” was false at 08:42, changed to true at 08:44, and has remained true for the subsequent two events.

Event Values Over Time

Switching on debug mode

Switch on the debug tools for the whole property by adjusting your analytics configuration tag to add debug_mode as shown below.

  gtag('config', 'G-AAAAAAAAAA', {'debug_mode': true});

Alternatively, you can set this flag on specific events, using the same debug_mode flag in your event data:

  gtag('event', 'MyCustomEvent', {
    'eventdata': 'ABC',
    'debug_mode': true

Correlating the session

Often, you need to pick your session out of several debug sessions that will appear on the DebugView page.

If you open up any event in DebugView, you’ll see a ga_session_id. You can correlate this with the sid being sent to the collect route. You can find this in the Network tab of your browser’s developer tools.

Written by Steve Fenton on