Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager isn't loading javascript, error message "anonymous function"

Tags:

I have installed Google Tag Manager on my website, and am using it to load some Javascript onto my site. However, GTM is no longer loading, my Javascript isn't loading, and the error code is not very helpful.

Here is the GTM code on my website:

<!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MFQ99J" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MFQ99J');</script> <!-- End Google Tag Manager --> 

This is the code I am including in the GTM Tag:

<!-- Qualaroo for your website --> <!-- Paste this code right after the <body> tag on every page of your site. --> <script type="text/javascript">   var _kiq = _kiq || [];   (function(){     setTimeout(function(){     var d = document, f = d.getElementsByTagName('script')[0], s = d.createElement('script'); s.type = 'text/javascript';     s.async = true; s.src = '//s3.amazonaws.com/ki.js/50553/aS-.js';f.parentNode.insertBefore(s, f);     }, 1);   })(); </script> 

When I look at the Chrome Javascript Console, I get the message:

(x) Failed to load resource     http://www.googletagmanager.com/ns.html?id=GTM-MFQ99J 

And when I reload the page, I see:

(x) GET http://www.googletagmanager.com/ns.html?id=GTM-MFQ99J    index.html:45         anonymous function                                       index.html:45         anonymous function                                       index.html:46 

Going to these lines gets me these lines from my GTM code:

'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MFQ99J');</script> 

I've been googling like crazy to try to figure this out, but I'm out of my depth for a lot of this. The error message "anonymous function" seems to be especially hard to search for, even within GTM and other Google support documentation.

like image 512
cgreene Avatar asked Jan 17 '14 20:01

cgreene


People also ask

Why is my tag not firing Google Tag Manager?

Sometimes a tag is not firing where it should because of multiple triggers or multiple rules within a trigger. The Solution: As all tags fire as a result of trigger configurations, this is normally the best place to start when tags are not firing as intended. Start by double checking your trigger settings.

Does Google Tag Manager use JavaScript?

The data layer is an object used by Google Tag Manager and gtag. js to pass information to tags. Events or variables can be passed via the data layer, and triggers can be set up based on the values of variables.

Is GTAG js the same as Google Tag Manager?

Tag Manager is a tag management system that allows you to quickly and easily update tags on your website or mobile app from a web interface. gtag. js is the JavaScript framework that is used to add Google tags directly to web pages.

Is Google Tag Manager going away?

The current version of Google Tag Manager (version 4, or “Legacy”) for mobile apps will no longer be supported by Google as of March 2020. But, limitations on the functionality of GTM version 4 have already begun.


1 Answers

I noticed the same issue when you don't have any published tag, once you publish the version the JS will load successfully.

https://www.youtube.com/watch?v=KRvbFpeZ11Y#t=179

like image 109
talsibony Avatar answered Oct 19 '22 22:10

talsibony