How to Install Lazy Google Analytics to Speed up Your Blog Loading

 How to Install Lazy Google Analytics to Speed up Your Blog Loading

  
lazy analytics

- Hello blogger friends, on this occasion I will discuss How To install Lazy Google Analytics, To Speed ​​Up Blog Loading yep why am I discussing this because many website or blog owners who have installed Google analytics experience problems loading their blogs.

Analytics JS from google is one of the high load scores for blogs. And this is undeniably a common problem for bloggers.

By using this Lazy method, we can avoid the blocking effect rendering from Google Analytics by Delaying and saving JavaScript snippets analytics (caching) for faster page loading and improvements user experience.

How To install Lazy Google Analytics

For those of you who have installed Google Analytics on a blog template. So generally, the script installation will look like this.
<script async='async' src='https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x'/> 

<script type='text/javascript'>//<![CDATA[var lazyanalisis=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===lazyanalisis||0!=document.body.scrollTop&&!1===lazyanalisis)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://www.googletagmanager.com/gtag/js?id=UA-138679495-2";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyanalisis=!0)},!0);//]]></script> 

or 

<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-YG9FNZVFSM"></script> <script>   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag('js', new Date());   gtag('config', 'G-YG9FNZVFSM'); </script>

 

Just Remove <script async='async' src='https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x'/> 

then add this below script above </body>
<script type='text/javascript'>//<![CDATA[ var lazyanalisis=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===lazyanalisis||0!=document.body.scrollTop&&!1===lazyanalisis)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://www.googletagmanager.com/gtag/js?id=UA-138679495-2";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyanalisis=!0)},!0); //]]></script>

ENGLISH
<script type='text/javascript'>//<![CDATA[ var lazyanalisis=!1;window.addEventListener("scroll",function(){(0!=document.documentElement.scrollTop&&!1===lazyanalisis||0!=document.body.scrollTop&&!1===lazyanalisis)&&(!function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://www.googletagmanager.com/gtag/js?id=UA-138679495-2";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyanalisis=!0)},!0); //]]></script>

Then save the theme


Post a Comment

Previous Post Next Post