How to Lazy Load Google Analytics to improve Website Performance in Blogger?

Lazy Load Google analytics to improve Website Performance and ready for Core web vitals

One of the most often used JavaScript library on a website is Google Analytics, which can have a render-blocking effect when the page is loaded. You can't just delete the code because it's essential for tracking website traffic. However, you may increase the page performance by lazyloading the Google analytics code on the Blogger website. Simply follow the instructions in this article.

Lazy Load Google analytics

Importance of Google Analytics Lazy Load

Google Analytics is a free monitoring tool that provides detailed information on how visitors interact with your website.

However, if not correctly done, it might cause your blog to load slowly. In general, Google Analytics makes three HTTP queries and takes between 100 and 500 milliseconds. You may simply save time by postponing the Analytics code's loading.

Do you know that placing the analytics code in the footer instead of the header can reduce page load time by 100 milliseconds? It can fix PageSpeed render-blocking Javascript and content above-the-fold problems.

How to add Lazy Analytics Google analytics?

  1. Remove the Google Analytics property ID from the Blogger settings page.
  2. Now go to the theme area and back up your theme for safe installation.
  3. Now, choose Edit HTML and search for analytics and delete any old analytics code.
  4. Code our new analytics code below and paste it above </body> tag or  &lt;/body&gt; (you can find it at the end of your theme codes.
  5. Before save, replace the highlighted parts with your G-00000 or UA-00000 I'd.
  6. This will support GA3 and GA4.

<!-- [ Lazy Analytics Plugin by gamenewsmania.in ] --> <script type='text/javascript'>//<![CDATA[ var lazymyTraffic=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===lazymyTraffic||0!=document.body.scrollTop&&!1===lazymyTraffic)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://www.googletagmanager.com/gtag/js?id=G-00000000";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazymyTraffic=!0)},!0);//]]></script>  <script>  window.dataLayer = window.dataLayer || [];  function gtag(){dataLayer.push(arguments);}  gtag('js', new Date()); gtag('config', 'G-00000000'); </script> <!-- [ Lazy Analytics Loaded ] -->
Lazy Analytics Plugin by gamenewsmania.in.txt Script 751 B .txt

Note that universal analytics will stop working after July 1, 2023. So if you are using UA (GA3), then update to G (GA4) codes.

The lazy analytics code is now uploaded to your blogger website when you save your theme. Now check to see if your analytics code is working properly. This is how you can add Google Analytics code to Blogger and speed up the loading process.

Getting Info...
Hi there! I am a part time blogger from India and i like to coding in free times.

Buy me a Coffee

Post a Comment

Share your thoughts here! Communicate with other readers. Your comments will visible after getting approved by the editors.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage and improve this website, we request you to whitelist our website in your adblocking plugin/browser.