How to lazyload Google Analytics code in Blogger

How to lazyload Google Analytics code in Blogger
How to lazyload Google Analytics code in Blogger

Google Analytics is one of the most commonly used javascript codes on a website, and it may produce a render-blocking effect while the page is loaded.

You cannot just remove the code because it is quite useful in tracking visitors to the website. However, you may simply enhance page speed by lazyloading the Google analytics code on the Blogger website. Simply follow the methods outlined in this article.

How does Google analytics Affect Page speed?

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

However, if not properly implemented, it can cause your blog to load slowly. Google Analytics typically adds up to three HTTP requests and takes between 100 and 500 milliseconds.

You can simply save this time by delaying the Analytics code's execution.

Did you know that putting 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 above-the-fold content issues.

However, you can increase page speed even more by lazyloading the analytics code on your website. The analytics code will not load unless the page has fully loaded and the user has begun scrolling.

As a result, it will not interfere with the First Contentful Paint (FCP) and Largest Contentful Paint (LCP), which are critical elements in core web vitals. It also minimizes overall webpage size and speeds up website loading.

Why Lazyload Google Analytics is Important?

Lazy loading is a strategy that involves only loading photos, movies, or other media assets on a web page when the user scrolls to the bottom of the page. This strategy not only speeds up your blog's loading time, but it also saves bandwidth and server resources.

Google Analytics is a web-based service that gives precise information on website traffic and its sources, as well as insights into how visitors interact with webpages. It provides a free analytics package for bloggers that want to know how people get to their blogs and what they do while there.

Google Analytics is an useful tool for tracking your website's traffic. It can also give you information on how people interact with your blog.

There are several ways that may be utilized to reduce the time it takes for your blogger page to load. For blogger websites, one such strategy is to use sluggish load Google analytics.

Lazyload Google analytics for blogger blogs is an effective approach to ensure that your blog's loading time remains as short as feasible.

It will also help you save a lot of bandwidth and server resources, resulting in faster page loads and loading times for your visitors.

How To Install Lazy loaded Google Analytics code in Blogger?

Step 1: First and foremost, you must remove all previously placed Google analytics codes.

Step 2: Now you must create a backup of your theme.

Step 3: Copy the code below and make sure to change "Google analytics Id" to "Your Google analytics Id." (UA-xxxxxxxxxx).

Step 4: Now, Paste the Code Just Above the closing </body> Tag.

<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-xxxxxxxxxx";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(e,a)}(),lazyanalisis=!0)},!0);

//]]></script>

<script>

//<![CDATA[

  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'UA-xxxxxxxxxx');

//]]>

</script> 
Step 5: Now save theme.

Conclusion

Now you know how to lazyload Analytics code in Blogger to increase page loading speed. You can enquire of me in the comments section if you have any questions about this.

Next Post Previous Post
No Comment
Add Comment
comment url