Analytics
2K members online now
2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

GTM container loading error : DL event 'gtm.dom' & 'gtm.load' not being pushed

Follower ✭ ✭ ✭
# 1
Follower ✭ ✭ ✭

Hey guys,

 

I think I reached limits on my JS skills in order to debug with-in GTM library code Smiley Wink. Can anyone pls. tell me what’s the implication of this piece of code right after GTM container tag. Attach screenshot of GTM debug screen, as you can see GTM container loading gets stuck mid-way (something to do with null value being pushed to DL?)
//////////////////////////////////////

<script>
var t = null;
try {
dataLayer.push(t);
console.log("pushed dataLayer pairs2")
}
catch (x) {
console.log("ERROR~~~")
console.log(x);
console.log("====");
}
</script>

///////////////////////////////////////

fyi, I notice things go awry only when variable ’t’ is null. For non-null values (var t=123, for example), things work like a charm: GTM container loads perfectly - gtm.js > gtm.dom > gtm.load events - and subsequent dataLayer.push() statements work normally)


NOTE: You can use this link (>> click link to https://jsbin.com demo) in order to open GTM container in debug mode at your end:
https://www.googletagmanager.com/set_cookie?uiv2&id=GTM-T8NHQN&gtm_auth=lhqXxMkErpwewEcCvQY4IQ&gtm_p...

 

Thanks a lot for your insights on this.

 

Cheers!

 

localhost_test_.png

Re: GTM container loading error : DL event 'gtm.dom' &amp; 'gtm.load' not being pushed

Follower ✭ ✭ ✭
# 2
Follower ✭ ✭ ✭

@Vibhor J

 

I hope you are doing well !

 

As per my observation you are passing null as a string into dataLayer without Single/double quote. Please pass the same in quotes. 

 

Please refer the screenshot for your reference.

dataLayerJs.JPG

GTM container loading error : DL event 'gtm.dom' &amp;amp; 'gtm.load' not being pushed

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭

Thanks Wasim for taking your time.

True, we're not passing an object as Key / Value pair into DL. How come I could pass dataLayer.push("123") or dataLayer.push(123) and things work perfectly then

 

I think I can pass any object to dataLayer.push(), at the end dataLayer is an Array of objects, but I notice, only when I pass null value, things start to break. This doesn't happen with any non-null value,  be it key / value pair or object in itself.

 

cheers!