Sub topic 12
Testing with DebugView and Realtime
You have designed the lead and sale events, added value and currency, and sent them with gtag.js or Google Tag Manager (GTM). This chapter covers how to confirm that GA4 receives those events the way you intended, before you mark them as key events and depend on the numbers.
This chapter assumes four things:
- You have Editor access to a GA4 property with a web data stream.
- You can edit the site's code or a GTM container.
- You know the event and parameter model.
- You have implemented at least one test event, such as
generate_leadorpurchase.
Why you test in two places
GA4 gives you two views for checking incoming data. They answer different questions.
- DebugView shows the events and parameters from one device that you flagged as a debug device. It answers "Did my event arrive with the right parameters?"
- Realtime shows aggregated activity from all users in roughly the last 30 minutes. It answers "Is the event arriving at all, and is it counted as a key event?"
| Question | DebugView | Realtime |
|---|---|---|
| Whose traffic is shown | Only devices in debug mode | All visitors |
| Parameter values visible | Yes, per event | No, only counts |
| Detail level | Seconds-by-seconds timeline | Aggregate cards and tables |
| Shows the key event flag | Yes | Yes, in the Key events column |
| Best for | Checking one event's payload | Checking live volume and marking status |
You find DebugView in Admin under Data display > DebugView. You find Realtime in Reports > Realtime.
The testing loop
The sequence below keeps you from marking an event that is malformed or fires at the wrong time.
Turning on debug mode
DebugView only lists events from devices that report in debug mode. You have three common ways to enable it.
- GTM Preview mode. When you click Preview and connect Tag Assistant to your site, GTM sends the GA4 hits in debug mode automatically. This is the easiest route if you use GTM.
- The
debug_modeparameter in gtag.js. Set it in the configuration, or on a single event. - A browser debugging extension. Google's GA debugger extension for Chrome adds debug mode to hits from your browser.
For gtag.js, this page enables debug mode for every hit from the page and then sends a test lead event:
<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());
// debug_mode makes this device appear in DebugView
gtag('config', 'G-XXXXXXXXXX', { debug_mode: true });
// Test lead event: fire it from your real form handler in production
gtag('event', 'generate_lead', {
currency: 'USD',
value: 25.00
});
</script>Replace G-XXXXXXXXXX with your measurement ID. Remove debug_mode: true before you publish, or limit it to your own testing sessions. Otherwise every visitor becomes a debug device and DebugView stops being useful.
Reading DebugView
Open DebugView and pick your device in the Debug device selector at the top left. If several people test at once, the list can hold more than one device. Use the page you are on and the timing of your own actions to tell them apart.
The view has three parts:
- Minutes stream (left): events grouped by minute, so you can see the overall sequence.
- Seconds stream (center): individual events in order, newest at the top. Click an event name to expand its parameters.
- Top events and user properties (right): counts of events seen from this device and the user properties that were set.
A key event carries a flag icon next to its name once you have marked it. Before marking, the flag is absent. That is expected.
What to check on each event
For a generate_lead event, click it and check:
- The event name is spelled exactly
generate_lead. A name such asgenerateLeadis a different custom event. valueis a number such as25, not a string like"$25".currencyis a three-letter ISO 4217 code such asUSD. Without it, value is not reported correctly in monetary reports.- No parameter contains personal data such as an email address or phone number.
For a purchase event, also check:
transaction_idis present and unique for each order.valuematches the order total you intended to report.itemscontains the expected entries, each withitem_idoritem_name,price, andquantity.
Count the events
Perform the action once and count the events. If you submit the form once and see two generate_lead events, the trigger is firing twice. Common causes are a listener attached on every page view, or both a GTM tag and a hard-coded gtag call sending the same event.
Testing purchases and duplicates
The purchase event usually fires from a confirmation page, so reloading that page is a realistic test. Run it deliberately:
- Complete a test order and watch for one
purchaseevent in DebugView. - Reload the confirmation page.
- Watch whether a second
purchaseevent appears.
DebugView shows every hit it receives, so a second event will appear if your code fires again. GA4 uses transaction_id to avoid counting repeated purchases in reports, but you should still stop the double fire at the source. Relying on processing to hide the problem leaves noise in your tags and makes testing harder.
In GTM, you can check the dataLayer in the browser console before you look at GA4:
// Run in the browser console on the confirmation page
const purchases = window.dataLayer.filter(
(entry) => entry.event === 'purchase'
);
console.log('purchase pushes:', purchases.length);
console.log(JSON.stringify(purchases, null, 2));If this prints more than one push for a single order, the duplicate comes from the site, not from GA4.
Confirming in Realtime
DebugView proves the payload is correct. Realtime proves the event is reaching GA4 outside your debug session and shows how it is classified.
- Open Reports > Realtime.
- In the Event count by Event name card, find your event. There is a column for Key events in the table. A count appears there once the event is marked.
- Perform the action again and watch the count rise by one.
Realtime covers about the last 30 minutes and updates within seconds. Use it to confirm that a production page, not only your debug session, sends the event.
Marking status and timing
Marking an event as a key event applies from that moment forward. Events collected earlier are not changed. An event name may not appear in the Admin key events list until GA4 has received it at least once. If it is not listed, you can add the event name manually in Admin > Data display > Key events using New key event. The Events list in Admin can lag by up to a day, while DebugView and Realtime do not.
After marking, retest. Trigger the event and confirm that the flag appears in DebugView and that the Key events column in Realtime counts it.
When DebugView stays empty
If you see nothing, check these causes in order:
- Ad blockers and privacy extensions block the GA4 request. Test in a clean browser profile.
- Consent settings. If your consent banner has not granted analytics storage, GA4 may not send full hits. Accept the banner first, then test.
- Wrong property. Confirm the measurement ID in the tag matches the property you are viewing.
- Debug mode not applied. In GTM, make sure Tag Assistant shows the connected session. In gtag.js, make sure
debug_modeis in the configuration before the event. - Network failure. In browser developer tools, open the Network tab and filter for
collect. A request togoogle-analytics.com/g/collectwith the righten=event name confirms the hit left the browser.
A pre-launch checklist
- The event fires once per real user action.
- The name matches the plan exactly.
value,currency, andtransaction_idappear where required, with correct types.- No personal data appears in any parameter.
- The event appears in Realtime and carries the key event flag after marking.
- Debug mode and test filters are removed or controlled before launch.
Exercise
You submit a lead form once and DebugView shows two generate_lead events a few milliseconds apart. Name two likely causes and one way to confirm each.
Show answer
One cause is that two tags send the same event, for example a GTM GA4 event tag and a hard-coded gtag('event', 'generate_lead', ...) call. Confirm by looking at the tags that fired in Tag Assistant and by searching the page source for the gtag call. A second cause is that the form listener runs twice, for example because the script is included twice or the listener is attached on every render. Confirm by logging inside the handler or by checking window.dataLayer for two pushes of the same event.
Exercise
A purchase event appears correctly in DebugView, but the Key events column in Realtime shows 0 for it. What should you check, and why might old test purchases not be counted?
Show answer
Check whether purchase is marked as a key event in Admin under Data display > Key events. If it is not marked, Realtime will list the event but not count it as a key event. Marking applies only from that point forward, so purchases collected before you marked it are not counted as key events. Mark it, trigger a new test purchase, and confirm the flag in DebugView and the count in Realtime.