Google Analytics code is slowing down our website[ Edited ]
March 2017 - last edited March 2017
We have experienced slow loading time with Google Analytics code on our website. We ran the Gtmetrix test to see the requests waterfall, and it turns out that files in requests for page rendering are waiting for Google Analytics.js for 14 seconds. This is the analytics.js from - https://www.google-analytics.com/analytics.js Anyone else experienced this problem? I have never had a website loading such a long time before. Maybe someone has a solution? We use Google TAG manager for the analytics code.
Here is a screenshot with the waterfall:
Google Analytics code is slowing down our website
Google Analytics tracking code is asynchronous (a.async = 1), meaning that the browser doesn't need to wait for the code to finish loading to continue rendering elements that come after it on the page. The gtm.js will delay the window.load event if it fails to load in some browsers but it will not block the DOM-ready event.
To sum up, it's a good idea to get into the habit of placing the GTM container snippet in <head>, because that's where asynchronously loading libraries should be placed.
Recommend reading those articles:
All the best,