By Matthew Berry

Announced in late August/early September of 2017 the new ‘Gtag.js’ (Global Site Tag) tracking solution from Google has promised to bring a more unified tracking solution across multiple platforms in the Google stack.

Back to blog home

Designed and released to combat the ever changing landscape of online privacy using a method known as “Intelligent Tracking Prevention (ITP)” the 'Gtag.js' system was released just after Apple announced a change in the way cookie data would be stored on their browser, Safari.

Not only does this new tag bring a more uniform solution to tracking platforms such as Google Ads and Campaign Manager, but from a developer’s perspective the code is far more streamlined and has new syntax which facilitates the speedier implementation of custom tracking solutions.

A tracking code snippet but also an API, ‘Gtag.js’ allows the user to formulate and write custom configurations to send event data to their respective platforms. ‘Gtag.js’ still works with the same Javascript library that was used for Analytics.js however it is a much more refined version and streamlines processes and setups which at one point would have been far more convoluted. Despite all of the promised benefits of ‘Gtag.js’ it seems that as a tracking solution it is still in the process of having regular bugs worked out of it and fixes created. This said, undoubtedly it’ll reach its full potential in the next six months or so.

Do I need it?

The current recommendation from Google is that it is only worth using the ‘Gtag.js’ method if one is implementing tracking on their site for the first time and you’re not using Google Tag Manager. Because it runs on the same library as ‘Analytics.js’, if you’re already using this solution, stick with it and just implement the Conversion Linker tag to go with it.

One of the key advantages of switching to 'Gtag.js' is the ability to streamline your code and lower developer resource. The ability to track many different types of conversions from different Google platforms with one unified snippet is a huge plus for anyone who is looking for an efficient tracking solution across multiple Google platforms.

What does it look like?

Below is the basic tracking code snippet which must be implemented on each page of the site which will be tracked.

<script>
window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
</script>


Here we can see the different Google products being linked into the tracking snippet via the ‘config’ command.

<script>
 window.dataLayer = window.dataLayer || [];
 function gtag(){dataLayer.push(arguments);}
 gtag('js', new Date());
 gtag('config', 'GA-TRACKING_ID');
 gtag('config', 'AW-TRACKING_ID');
 gtag('config', 'DC-TRACKING_ID');
</script>


Below one can observe how ‘Gtag.js’ enables the utility to send data to multiple different GA accounts which are sorted by ‘group’ and ‘agency’ in order to better facilitate the cohabitation of multiple digital agencies on one client account.

<script>
 gtag('config', 'GA-TRACKING_ID-1');
 gtag('config', 'GA-TRACKING_ID-2', { 'groups': 'agency' });
 gtag('config', 'GA-TRACKING_ID-3', { 'groups': 'agency' });
</script>

Summary

If you are looking to implement analytics tracking on your website for the first time without Google Tag Manager and are interested in a unified solution for tracking between multiple Google products - ‘Gtag.js’ might be the answer for you. If you’d like to learn more about best practice Google Analytics implementation, get in touch with our Analytics team today!

Share this article