In recent years, a lot has changed in how Google measures conversions and website statistics. To keep up with the developments, Google introduced the new Global Site Tag (gtag.js) as general tracking code in late 2017. Since it is recommended by Google over the traditional analytics.js, we are increasingly seeing gtag.js implemented on websites and measurability being implemented in that way. So how can you adapt to this when you are (already) using Google Tag Manager (GTM)? Can GTM and gtag.js run side by side in harmony, without causing duplicate measurements? They certainly can! Read how to set this up correctly in this blog.
What is gtag.js?
But wait, weren’t we just getting started with GTM?
What is GTM?
Let’s come back to the question of whether we weren’t just doing a nice job with GTM. Basically, it is not necessary to put gtag.js on the website if you are already using GTM. After all, the advantages of GTM are:
You can easily make adjustments yourself.
The options are endless: GTM can be used for more than just Google products and is easy to customize.
GTM makes it easier to implement advanced Analytics features. Think of cross domain tracking, user ID tracking, etc.
It is well secured.
Debugging options. You can build in error checking and control, so that everything is debugged before it goes live.
How do I make a choice?
GTM and Google Analytics are two separate tools that can be used independently of each other. You can choose to use GTM alone, or you can choose to use gtag.js alone. In general, Google recommends tracking Analytics through GTM. However, this is not always possible. |Fortunately, GTM and gtag.js can be used well together, provided you know how to do so.
How do I use GTM and gtag.js together?
More and more we see that new websites are switching to gtag.js. Not surprising, considering Google recommends this tracking code over the old analytics.js. It is also happening more and more that conversions are being shot in via gtag.js. So when this is the case, it means that Analytics is hardcoded on the website. This potentially causes problems if you also want to do measurements via Google Tag Manager (GTM). For example, if you measure e-commerce via gtag.js, but manage soft conversions, such as newsletter subscriptions, via GTM. It can also cause problems when websites require both Google Analytics and GTM for extensive advanced Analytics tracking (Shopify, we’re looking at you).
When you want to use both GTM and gtag.js, you run the risk of duplicate measurements. Analytics can run through both, which is problematic. A large part of the GTM tags are based on an Analytics variable. This means that you probably have Google Analytics as a tag in GTM. And if there is also gtag.js on the website, this most likely means that there is double data coming in. Is there a way to have both Analytics and GTM on the website without duplicate data? The answer is yes.
The solution is to make sure that no Analytics ‘Page View’ is being fired from GTM. This means that you should not use the below (default) implementation of the Analytics tag in GTM:
You can still use a Universal Analytics tag in GTM that is fired on all pages. But instead of using tracking type ‘Page View’, choose tracking type ‘Event’ (see example below). This will eliminate duplicate page views, as you will have one pageview fired (gtag.js) and one event fired (GTM). You can see this event in the ‘Behavior’ section of Google Analytics.
Gtag.js is definitely an improvement over its predecessor analytics.js in terms of data collection. However, when you have the chance to set everything up through GTM, that is still the preferred option. If this is not possible, you can certainly use gtag.js and GTM side by side, but make sure that only one pageview is fished. That way you avoid duplicate data and can take advantage of the benefits of both gtag.js and GTM.