How to Boost Website Speed by hosting gtag.js locally

Do you know that hosting gtag.js locally can improve the speed of your website? If you are aware of the latest Core web vital update of Google, you must know that website speed becomes one of the ranking factors.

So if you want to improve your search ranking then you should try every possible way to improve the speed of your website.

Through this article, I have discussed how gtag.js slows down your website and how you can host this script locally. Before that let us first know what gtag.js is?

What is gtag.js?

Gtag.js is a JavaScript-based code snippet that helps you manage and track your website performance without needing to edit any HTML code. This code snippet helps to send all the performance events to Google Analytics. In easy language, Global site tags (Gtag.js) are a feature of Google Analytics and enable marketers and website owners to track traffic worldwide.

Global Site Tag allows you to use your site’s CMS to manage and deploy tags, so you don’t have to build or maintain a separate system for it. This can help save time and effort because there is no need for extra staff members or third-party developers.

How does gtag.js slow your website speed?

If you are a blogger or a website owner, you must be aware of the loading speed of your website. According to the latest algorithm update of Google, page speed becomes one of the most important ranking factors.

So, if your website’s loading time is high then external Javascript size can be one of the reasons and gtag.js is one of those scripts.

The speed of your website can be improved to some extent by hosting gtag.js locally and overall improves the core web vital score of your website. You can easily do it with the help of an amazing plugin known as Monsterinsight. 

The default cache time of Google is around 2 hours but if you host this script locally you can have full control over the caching of the file and ultimately this will help you to reduce the loading time of your website.

In the later part of this article, I will explain how to host gtag.js locally in just a few clicks with Monsterinsight.

Overview of MonsterInsight Plugin

Monsterinsight is the #1 Google analytics plugin for WordPress. If you want a plugin for tracking your website’s performance, real-time analytics, search rankings, user behavior, eCommerce report, then Monsterinsight can be the best choice for you.

Currently, more than 3 million professionals use this plugin to grow their online businesses. Monsterinsight can be integrated with many popular WordPress plugins like Woocommerce, Yoast, WPForms, AMP, Pretty Links, and many more.

This is must have WordPress plugin for bloggers, available in both a free version and premium versions. You can easily download the free version from your WordPress plugin repository. The premium version is available on the official site of Monsterinsight starting at $99.50 per year. 14 Day money-back guarantee included with all the premium plans.

Features of Monsterinsight

Let us see the features of Monsterinsight and why to use it as a Google Analytics plugin for WordPress.

1. Quick and easy setup – If you are a beginner and do not have much experience in WordPress, then Monsterinsight is going to be very helpful for you. It will hardly take a few minutes to set up this analytics plugin for your WordPress site.

2. Search Console report – Monsterinsight allows you to access your Search console details right from your WordPress dashboard. You can say it is an all-in-one analytics plugin for your site.

3. Affiliate link tracking – This feature is very helpful for bloggers and affiliate marketers. With the help of Monsterinsight, you can accurately track the performance of your affiliate links.

4. eCommerce performance tracking – If you have an eCommerce store and want to track the performance then Monsterinsight can help you to do so. It comes with 1-click Google analytics enhanced eCommerce tracking for Woocommerce, Easy digital downloads, and Memberpress.

5. Site Speed report – The site speed report of Monsterinsight will help you to improve the user experience and ranking of your site by identifying all the possible ways to improve the speed of your website.

6. Scroll tracking – With the help of Monsterinsight, you can enable Scroll tracking of your website, which will help you to know the user’s engagement on your site. 

How to host gtaj.js locally (with Monsterinsight)

If you are a Monsterinsight user, then you have definitely received the latest Monsterinsight 7.18 update. In this update, they have added a new feature of hosting gtag.js locally. Hosting gtag.js locally will definitely help you improve your website’s speed and help you pass the core web vital tests. 

Performance addon by Monsterinsight

In this latest update, Monterinsight comes up with a new addon known as performance addon and this addon will help you to boost your site speed by hosting gtag.js locally.

How to Boost Website Speed by hosting gtag.js locally 1

To install and activate the performances addon follow the steps given below:

Click on insight>> Addon>> Click on the install button of the performance addon. That’s it, the performance addon of Monsterinsight is now added successfully.

How to Boost Website Speed by hosting gtag.js locally 2

This performance addon will automatically fetch the latest gtag.js file from Google every 24 hours to keep it up to date and provide you the latest stats.

After you install and activate the performance addon, you can manually set the sample rate and site speed sample rate.

In case you don’t know what is sample rate and site speed sample rate are, let me explain to you in brief. The sample rate basically specifies the percentage of users that should be tracked and the site speed sample rate determines how often site speed tracking will be sent.

To change the sample rate and site speed tracking, follow the steps given below:

Click on insight>> Settings>> Go to Performance

Here you can manually set the sample rate and site speed sample rate. By default, the site speed sample rate will be 1%.


To qualify core web vital test of Google you should try every possible way to improve the speed of your website. You should try hosting gtag.js locally using Monsterinsight and you will definitely see improvements in the speed of your website.