How to Speed Up Your Blog with Lazyload Google Analytics Code in Blogger

How to Add Lazyload Google Analytics Code to Blogger Website in 4 Easy Steps and Speed Up Your Blog Loading Time

Google Analytics is a powerful tool that helps you track and analyze your website traffic. But did you know that it can also slow down your blog loading time if you don’t implement it properly?

Google Analytics adds up to 3 HTTP requests and takes around 100 milliseconds to 500 milliseconds to load. This can affect your page speed score and core web vitals, which are important factors for SEO and user experience.

One way to solve this problem is to lazyload the Google analytics code in your Blogger website. This means that the analytics code will not load until the page is fully loaded and the user starts scrolling. This way, it will not interfere with the first contentful paint (FCP) and largest contentful paint (LCP), which are the key elements in core web vitals.

In this article, I will show you how to add Lazyload Google analytics code to Blogger website and speed up your blog loading time. This is a simple and effective method that can improve your page speed score and core web vitals.

What is Lazyload Google analytics code?

Lazyload Google analytics code is a technique that delays the loading of the analytics code until the user scrolls down the page. This reduces the number of HTTP requests and the page size, which can improve the page loading time.

Lazyloading the Google analytics code can also help you avoid render-blocking JavaScript errors, which can negatively impact your page speed score and core web vitals.

By lazyloading the Google analytics code, you can still get all the benefits of tracking your website traffic without compromising your blog performance.

How to add Lazyload Google analytics code to Blogger website?

Adding Lazyload Google analytics code to Blogger website is easy and straightforward. You just need to follow these steps:

Step 1: Remove the Google Analytics property ID from Blogger settings

The first step is to remove the Google Analytics property ID from your Blogger settings. This will prevent any conflicts or errors with the lazyloaded analytics code.

To do this, go to your Blogger dashboard and click on Settings. Then, scroll down to Other and find Google Analytics Property ID. Delete the property ID from the box and save your settings.

Step 2: Backup your Blogger theme

The next step is to backup your Blogger theme before making any changes to the HTML code. This will help you restore your theme in case anything goes wrong.

To backup your Blogger theme, go to your Blogger dashboard and click on Theme. Then, click on Backup/Restore at the top right corner. A pop-up window will appear where you can download your theme as an XML file. Save it somewhere safe on your computer.

Step 3: Edit your Blogger HTML code

The third step is to edit your Blogger HTML code and insert the lazyloaded analytics code. You will need to find and remove any old analytics code if you have previously added it.

To edit your Blogger HTML code, go to your Blogger dashboard and click on Theme. Then, click on Edit HTML at the top left corner. A window will open where you can see and edit your theme’s HTML code.

To find any old analytics code, press Ctrl+F on your keyboard and search for “analytics”. If you find any script tags that contain “analytics” or “gtag”, delete them from the code.

The old analytics code will look something like this:

script
<script async=‘async’ src=‘https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x’/> <script> //<![CDATA[ window.dataLayer = window.dataLayer || []; function gtag () {dataLayer.push (arguments);} gtag (‘js’, new Date ()); gtag (‘config’, ’ UA-xxxxxxx-x '); //]]> </script>

Delete this part from the code and save your changes.

Step 4: Add the lazyloaded analytics code

The final step is to add the lazyloaded analytics code just above the </body> tag in your HTML code. You will need to replace the tracking code with your own Google Analytics property ID.

The lazyloaded analytics code will look something like this:

script
<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 async=‘async’ src=‘https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x’/> <script> //<![CDATA[ window.dataLayer = window.dataLayer || []; function gtag () {dataLayer.push (arguments);} gtag (‘js’, new Date ()); gtag (‘config’, ’ UA-xxxxxxx-x '); //]]> </script>

Here, you need to replace the tracking code (highlighted) in both of the scripts with your own Google Analytics property ID. You can find your property ID in your Google Analytics account under Admin > Property > Property Settings.

Copy and paste the lazyloaded analytics code just above the </body> tag in your HTML code and save your changes.

That’s it! You have successfully added Lazyload Google analytics code to Blogger website and speed up your blog loading time.

FAQs

What are the benefits of adding Lazyload Google analytics code to Blogger website?

Some of the benefits of adding Lazyload Google analytics code to Blogger website are:

  • It can improve your page speed score and core web vitals, which are important for SEO and user experience.
  • It can reduce the number of HTTP requests and the page size, which can make your blog load faster.
  • It can avoid render-blocking JavaScript errors, which can negatively impact your page speed score and core web vitals.
  • It can still track and analyze your website traffic without compromising your blog performance.

How can I test if Lazyload Google analytics code is working on my Blogger website?

One way to test if Lazyload Google analytics code is working on your Blogger website is to use a tool like GTmetrix or PageSpeed Insights. These tools can measure your page speed score and core web vitals, as well as show you how many HTTP requests and page size your blog has.

You can compare the results before and after adding Lazyload Google analytics code to Blogger website and see if there is any improvement.

Another way to test if Lazyload Google analytics code is working on your Blogger website is to use a tool like Chrome DevTools or Firefox Developer Tools. These tools can show you how the scripts are loaded on your blog and when they are executed.

You can open these tools by right-clicking on your blog and selecting Inspect or Inspect Element. Then, go to the Network tab and reload your blog. You can filter the scripts by typing “analytics” or “gtag” in the search box.

You should see that the analytics scripts are loaded after the page is fully loaded and when you scroll down the page. This means that they are lazyloaded and not interfering with the initial page loading.

Conclusion

Adding Lazyload Google analytics code to Blogger website is a simple and effective way to speed up your blog loading time and improve your page speed score and core web vitals.

By lazyloading the analytics code, you can reduce the number of HTTP requests and the page size, avoid render-blocking JavaScript errors, and still track and analyze your website traffic.

To add Lazyload Google analytics code to Blogger website, you just need to follow these steps:

  • Remove the Google Analytics property ID from Blogger settings
  • Backup your Blogger theme
  • Edit your Blogger HTML code and remove any old analytics code
  • Add the lazyloaded analytics code just above the </body> tag in your HTML code

I hope this article was helpful for you. If you have any questions or feedback, please leave a comment below. Thank you for reading!

المقالة التالية المقالة السابقة
لا توجد تعليقات
اضـف تعليق
comment url