Open utterances-bot opened 2 years ago
Thank you for sharing this. I implemented, via the footer of our site, and it worked great, but I am having trouble getting Pageviews to register, even with your fix in the code. Curious as to if you’ve experienced any issues with Pageviews since posting this? Thanks again for this great resource!
Sorry, but this is not working :( G tracking is not loaded :(
Sorry - seems to be working :)
I pasted this in my footer and the code is showing on my live site, I'm on webflow I'm not sure if that's the problem.
Thanks a lot. I pasted the code in the header, and it is also showing in the front end.
Thanks for the solution. I'm working with Webflow too, and it is also showing it in the front end...
Thank you so much, you are an absolute life saver!
Where do I add this script ?
The script works, you just need to follow certain steps:
1- Remove the Tag Manager code and replace it with the script. 2- Modify the script with the Tag Manager ID. 3- Add the script to the header of your website. 4- If GTmetrix still detects Tag Manager, adjust the variable setTimeout(initGTM, 3500);. In my case, my website loaded before 3 seconds, so adjusting the value to setTimeout(initGTM, 2500); worked perfectly. Note: Perform tests, especially with events and conversions, including Facebook Ads, Google Ads, etc.
Hi. Thank you for such a great post! My website is on shopify and we have the google/you tube shopify app to link our GTM tag to our website. My question is: Should we replace the code provided by GTM and instead use your code? OR, should we use both? Thanks.
A real game changer!
Hello , i'm trying to use your code but on this line :" dataLayer.push({ event: 'gtm.js', 'gtm.start': new Date().getTime(), 'gtm.uniqueEventId': 0 }); "
I don't see where dalaLayer is been defined
@GodinhoB the dataLayer
is a global variable introduced by the gtm.js script if I recall correctly. So as soon as the script is loaded, dataLayer should be present. Try to go to any website that you believe have Google Analytics (like matas.dk) and type "dataLayer" in the console. You should see it hold some values
@bradandmoo sorry for the late response here. My code embeds gtm.js, so you'll need to disable any other way of adding Google Analytics, otherwise it would be added multiple times, which possibly could introduce unwanted results (and not provide the expected effect either)
Delay loading of Google Analytics / Google Tag Manager script for better PageSpeed score and initial load | Constant Solutions
This is a custom description for SEO and Open Graph purposes, rather than the default generated excerpt. Simply add a description field to the frontmatter.
http://localhost:8000/2020/06/delay-loading-of-google-analytics-google-tag-manager-script-for-better-pagespeed-score-and-initial-load/