I am writing this post to explain, how to implement gtag.js for WordPress. It’s being few months since Google launches global site tag (gtag.js) for google analytics.  Gtag.js is new tracking snipped provided by google analytics to implement into your website to get website performance report in google analytics.

Peoples had started migrating from universal analytics (analytics.js) to global site tag (gtag.js).  migration is quite easy for those who have static HTML website or custom dynamic websites developed with PHP, JSP, ASP or any other programming languages because in this type of websites you just need to replace existing universal analytics (analytics.js) with new global site tag (gtag.js).

But, millions of website owners who are using WordPress CMS, it’s very difficult task because most of WordPress website owners using plugins  to implement google analytics tracking and till now (25th Oct 2017) NONE of existing plugins are supporting google analytics global site tag (gtag.js).

When I search for gtag.js in plugin section of wordpress.org it could not find any result.

When I search for global site tag, it is returning incorrect results.

Several google analytics plugin users are now asking questions about gtag.js to plugin developers.

One such plugin user of Google Analytics Dashboard for WP (GADWP), BobFest asked.

Hi Alin – great plugin, thanks for all your work.

Wondering about support for gtag.js that now shows within my GA account as the default tracking code and sounds like it will eventually replace analytics.js.

Plugin Author Alin Marcu replied to this question


As far as I know, gtag.js is in Beta stage and some analytics.js features are not covered.

Considering the above, it’s clear that the move will be made at a stable stage.

This conversation clearly indicates that WordPress plugin developers are not willing to put effort to develop a new plugin or add support in existing plugin for global site tag (gtag.js) since it is beta launch.

Without having WordPress plugin for global site tag (gtag.js), you can still implement gtag.js in your WordPress website. There are two ways.

  1. Custom JS Plugin: install any available custom JS plugin that can insert JavaScript code in <head>.  I will suggest installing Simple Custom CSS and JS WordPress plugin. With the help of this plugin, you can easily install gtag.js tracking code into your website.   Follow given steps
  2. Install Simple Custom CSS and JS WordPress Plugin
  3. Click on Add Custom JS from left menu
  4. Give name of this file
  5. Paste given code inside editor
  6. Select linking type external
  7. select header from where on page

2) Theme Panel Option for Analytics: All modern and advance theme comes with the option to insert google analytics code. Try to find out analytics or custom JavaScript option in theme panel and insert global site tag (gtag.js) code here. 

Conclusion:  Google analytics introduces global site tag (gtag.js) to provides a framework for streamlined web page tagging – giving you better control while making implementation easier.   With the help of this code google analytics will show some more useful reports that will website owners to understand visitors behavior in a better way.  Once it’s full version will launch, plugin developers will surely come up with a great plugin for WordPress.  Till then, use above given methods.