Adding gtag.js to your site

Last Updated on March 4, 2018 by Chris Christoff

You probably have noticed that the default Analytics tracking code format, listed in your Properties, has changed a few months ago. Over the years, Google has released multiple versions of its Analytics JavaScript library, introducing new features. Global Site Tag is not the same thing. Is designed to simplify and streamline website tagging for Google products as Analytics, AdWords, and Doubleclick. Unlike the standard analytics.js library, global site tag (gtag.js) is a tagging framework and API that allows you to send data to multiple products.

From version 5.3, Google Analytics Dashboard for WP provides full support for gtag.js tracking. This means that almost all features available for analytics.js tracking are also supported when enabling the new Global Site Tag tracking code.

Things to consider before switching to gtag.js

Here are a few things to consider before migrating to gtag.js:

  • If you’re using Accelerated Mobile Pages, the AMP Client ID API is not supported yet (or I’m not yet aware of it being). This means that you probably won’t be able to uniquely identify and analyze a user’s experience across AMP and non-AMP content.
  • If you’re using an Ecommerce tracking plugin, make sure the plugin supports the new Global Site Tag tracking code.
  • Global Site Tag tracking uses the Enhanced ecommerce library by default, so you won’t be able to switch to Ecommerce or to Disable in plugin’s settings.
  • If you have defined custom events, outside of the GADWP plugin, make sure you update the code accordingly.
  • forceSSL parameter is set to true in gtag.js, so you won’t be able to disable it from plugin’s options.
  • To track user timing, Navigation Timing API is used. The rate at which timing events are sampled is determined by the total number of pageviews received during the previous day. These being said, the Speed Sample Rate setting is completely ignored.

To wrap things up, the most important issues you should be aware of, are the first two. Beside these, there are no notable things to consider.

Adding gtag.js to your site

Since almost all features available in GADWP are supported by gtag.js, I’ve decided to introduce a simple switch on/off button on the main Tracking Code screen, under Google Analytics -> Tracking Code.

To switch from analytics.js to gtag.js simply enable the option called use global site tag gtag.js (not recommended).

Google Analytics with gtag.js in GADWP

Other Release Notes

  • In Google Analytics Dashboard for WP v5.3 I’ve also added support for custom dimensions while tracking AMP pages using Google Tag Manager.
  • Google Tag Manager now has a native scroll depth tracking feature, available for both AMP and Web containers. For this reason, the GADWP’s scroll depth tracking feature is not available anymore in tag manager mode. Please use the native feature instead.
  • Button submits are now also tracked when track form submit actions option is enabled.
  • Users upgrading from a version lower than GADWP 5.2 will automatically be using the GADWP EndPoint.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.