Quick answer: Why your data layer event is not firing
When a dataLayer.push() event does not trigger a GTM tag, the usual causes are mismatched event names, the wrong trigger type, consent rules, tag exceptions or an incorrect container. The event key tells Google Tag Manager when to evaluate Custom Event triggers. A data layer variable alone does not fire a tag.
Start with Tag Assistant's Preview panel. You need to see the custom event in the timeline, then inspect why the intended tag fired or was blocked.
Working dataLayer.push example
Add an event when a real action succeeds, such as a verified form submission. The following example only pushes the event when your application calls the function:
<script>
window.dataLayer = window.dataLayer || [];
function trackSuccessfulLead() {
window.dataLayer.push({
event: 'lead_form_success',
form_type: 'contact'
});
}
</script>
Do not call this function on every page load. Invoke it only after the contact form has actually succeeded. Never include the visitor's email, name, phone or message in analytics event parameters.
Configure the Custom Event trigger correctly
- In GTM, open Triggers → New → Custom Event.
- Enter
lead_form_successas the Event Name, using identical spelling and capitalization. - Choose All Custom Events while testing. Add scope conditions after verifying the basic trigger works.
- Create or open the intended GA4 Event tag and attach this trigger.
- Open Preview, perform the form action, select the event and inspect Tags Fired and Tags Not Fired.
If the tag still fails, inspect blocking triggers, consent, container publication status and whether another script overwrites window.dataLayer after GTM loads.
Why a data layer variable can show undefined
The event's property and GTM's Data Layer Variable name must match. In the example above, the variable name is form_type, not formType. Push the value alongside the event so the tag can read it at firing time.
Do not reinitialize the data layer with window.dataLayer = [] after GTM has loaded. That can discard queued events or break GTM's current reference. Google's data layer documentation explains event processing order.
If GTM fires but GA4 reports remain empty, follow GA4 DebugView troubleshooting.
Tag Assistant diagnosis: What each result means
Custom event missing from Preview: the page may not execute the push, the action may have failed, or the preview is connected to another site or container. Check the browser console for JavaScript errors.
Custom event visible but tag not fired: check the tag's trigger, exception conditions, consent requirement and firing option. A tag attached only to All Pages will not automatically fire on your new event.
Tag fired but nothing in GA4: check the measurement setup, network restrictions and DebugView collection. Separate these stages rather than rewriting both website JavaScript and tag configuration at once. For an example of link-based events, read WhatsApp click tracking with GTM.
Frequently asked questions
Is an event name case-sensitive?
Use the same exact capitalization in the data layer push and Custom Event trigger to prevent mismatches.
Does dataLayer.push send data directly to GA4?
No. GTM needs a tag and matching trigger to send a GA4 event.
Should I republish the container after editing a trigger?
Preview first; publish the tested changes when they are ready for live visitors.
For implementation help, see MTP DigiTech's analytics services.
Need reliable analytics and conversion tracking?
We can review GA4, Tag Manager, event definitions and reporting accuracy before you optimize for leads.
Request Analytics Support →