Google Tag Manager isn't loading javascript, error message "anonymous function"
Solution 1
Do you have adblock plus installed? It used to block googletagmanager.com. The errors looked just like this.
Try disabling it and refreshing the page. If that fixes it, all you need to do is update your AdBlock filters. Google and AdBlock worked this out in early 2013, so updated versions of AdBlock filters will stop blocking google tag manager.
Also, it looks like you're using Google Tag Manager to load Qualaroo surveys. Please don't bother Qualaroo's customer service with this problem; it's not their fault Google got themselves blacklisted by AdBlock.
Solution 2
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
Related videos on Youtube
cgreene
Updated on July 09, 2022Comments
-
cgreene almost 2 years
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.
-
Mike Causer over 10 yearsThe
ns.html
page is inside a<noscript>
tag and is a fallback if you have javascript disabled. Only one of them should load. With or without js. -
Mukesh Chapagain over 7 yearsPossible duplicate of 404 error for Google Tag Manager
-
-
cgreene over 10 yearsThank you! I went through all my filters, and the EasyPrivacy list had the Google Tag Manager URLs on their list. I disabled this, and everything shows up fine now.
-
Jake Toronto over 9 yearsI think this should be the accepted answer. As the accepted answer says, AdBlock stopped blocking Google Tag Manager in 2013.
-
strattonn almost 9 yearsAgreed. I was getting those errors simply because I was still in preview mode, publishing "fixed" the errors.
-
Milche Patern over 8 yearsTo add to answer : i just had the 'ad blocker' blocking gtm issue.
-
Pramod Kharade over 6 yearsI also facing same issue but there is no such adblocker filter on my browser VM3280:1 Uncaught TypeError: $ is not a function at <anonymous>:1:13 at gtm.js?id=GTM-PN9B92:45 at gtm.js?id=GTM-PN9B92:46 at Object.c (gtm.js?id=GTM-PN9B92:48) at Tf (gtm.js?id=GTM-PN9B92:70) at Cl.H (gtm.js?id=GTM-PN9B92:167) at Ml (gtm.js?id=GTM-PN9B92:162) at Hg (gtm.js?id=GTM-PN9B92:169) at Tg (gtm.js?id=GTM-PN9B92:84) at Array.Vg.a.push (gtm.js?id=GTM-PN9B92:85): this is magento 2
-
vcoppolecchia over 5 years@pramod-kharade this happened to me many times and is related to your tags inside Google Tag Manager, not GTM itself: you should first load in your page jQuery then launch that specific GTM tag. That error is related to jQuery not yet being loaded in the page.
-
dance2die over 2 yearsThis answer still works on Oct, 2021. Turned off UBlock Origin and it works now.