How to install gtag.js on WordPress

Written By Tech in the Sun

Blogging Tools

This page contains affiliate links to products. We may receive a small commission for purchases made through these links while your purchase price stays the same.


Have you heard of Google’s new tracking code system (gtag.js)? Perhaps you have the older version installed and are considering upgrading the new system. This is how: with the MonsterInsights plugin and the new MonsterInsights Global Site Tag support.

This process doesn’t just enable a switch to the newly released Universal Analytics for Web (gtag.js); it also works towards improving the precision of your Google Analytics setup. In this guide, we will walk you through the steps, offering some handy pointers to ensure a successful transition. Yes, it’s as straightforward and effortless as it sounds! So, let’s jump right in.

What gtag.js is and why it’s important

For any brand-new Google Analytics account, gtag.js is the suggested tracking method. Furthermore, the global site tag works with another code: an event snippet when you track website conversions or a phone snippet when you track calls to your website. This replaces your business phone number with a Google forwarding number. 

There are a few reasons why the global site tag is the recommended tracking method, and they’re not too difficult to understand. The gtag.js by Google Ads supports multiple Google products such as Google Marketing Platform and Google Analytics. For that reason, gtag.js provides easier integration with other Google products and allows them to communicate more easily when sending data.

Indeed, a better integration also means more accurate conversion tracking and complete coverage of all conversions. This ensures that all conversions are accounted for.

As you can easily understand, this new tracking code is essential. Google will be using gtag.js more and more to create new analytics features. Let’s find out how to set up and use it.

How do I install gtag.js on my WordPress site?

Google’s new tracking code snippet, Global Site Tag (gtag.js), can be easily installed into your WordPress site. The most up-to-date WordPress themes often include a dedicated area in the dashboard to embed them in the WordPress header.

However, one of the easiest ways to install Google Analytics codes on your site is by using the MonsterInsights plugin. This tool allows you to view your website’s statistics directly within WordPress without leaving your site. This way, everything is easily under control in a single dashboard.

Recently, MonsterInsights introduced support for the Global Site Tag (gtag.js), making it the default tracking code for all new users. After installing the MonsterInsights plugin, even those using the older code can switch from the old tracking code (analytics.js) to the Global Site Tag with a click.

passare dal vecchio codice di monitoraggio GA al gtag.js con il plugin MonsterInsights

For more information on implementing tracking codes and events with Google Analytics, click here.

If there are custom codes in your site or you have set up event tracking using another plugin, MonsterInsights will automatically detect analytics.js events and move them through the Global Site Tag (gtag.js).

MonsterInsights and gtag.js Global Site Tag

MonsterInsights is the best WordPress analytics plugin, used every day by 2,000,000+ Professionals to grow their businesses. This new feature introduced by the MonsterInsights plugin represents an interesting opportunity to speed up the transition between old and new codes. Moreover, it’s a perfect way to benefit from the improvements and future integrations accessible thanks to the gtag.js tracking code.

MonsterInsights pricing starts at $99.50 per year for the Plus plan, including gtag.js Global Site Tag. For more information click here