Edit
Contact us
Salocin Group Leaders in data and AI-enabled connected customer experiences
Edit Engineers of connected customer experiences
Join the Dots Independent, data-led media thinking for sustainable growth
Wood for Trees Optimisers of future fundraising performance
  • Home
  • Our services
    • Cloud solutions
    • Data science
    • Modern Data Platform
    • Privacy and AI compliance
  • Our partners
    • Microsoft
    • Apteco
    • Salesforce
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Salocin Group
    • Careers
  • Contact Salocin Group
  • Home
  • Who we are
    • B Corp
    • Careers
  • Our work
  • What we do
    • Intelligent data
    • Marketing technology
    • Transformational CRM
    • Our technology partners
    • Privacy review
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • Contact Edit
  • Home
  • Broadcast media
  • Digital media
  • Print
    • Direct mail
  • Data
    • Our work with Herdify
    • EPiC
  • Media agency
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Join the Dots
    • Careers
  • Contact Join the Dots
  • Home
  • Services
    • Actionable insight
    • Data discovery
    • Data engineering
    • Data hygiene
    • Privacy review
  • Products
    • InsightHub
    • Apteco
    • Microsoft
    • Data management
    • Consent and preference management
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Wood for Trees
    • Operating principles
    • Careers
  • Contact Wood for Trees
Blog

What we know about gtag.js, the new Google Analytics Global Tracking tag

By Edit | 2 Nov 2017

We published this a long time ago…

Some of the content in this post might be out of date, and some images and links may no longer work.

Discover who we are and how we may be able to help you today:

Learn more

In 2017, Google added some sneaky articles to their developer website and support website about a new analytics tag called gtag.js:

Add gtag.js to your site

Migrate from analytics.js to gtag.js

Basic web-tracking set-up (includes many “with gtag.js” articles): What do we know about gtag.js?

The existence of gtag.js means that the Google Analytics code is going to change from using analytic.js to using a new tag: gtag.js. That means there is going to be a code update for:

  • Pageview tracking (i.e. “normal Google Analytics tracking”)
  • Event tracking
  • Ecommerce tracking
  • Custom dimension/metric tracking
  • Client/User ID tracking
  • User timings
  • Exception tracking

This means you’ll need to plan to migrate your analytics once again. At the minute, analytics.js is still the operating standard for Google Analytics, and Google have yet to announce when gtag.js will be considered the new operating standard and if analytics.js will become deprecated.

If the migration from analytics.js to gtag.js is similar to the migration from ga.js to analytics.js, I would expect to see:

  • An alert in Google Analytics
  • A dedicated gtagt.js centre within Google Support, similar to the Universal Analytics one
  • The option of a gtag.js tag within Google Tag Manager

The official description of gtag.js from Google:

“gtag.js is the web tagging library that works for Google’s site measurement, conversion tracking, and remarketing products – giving you better control while making implementation easier. By using gtag.js, you will be able to benefit from the latest dynamic features and integrations as they become available.”

The web tracking set-up guide includes the new tag format:

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'GA_TRACKING_ID');
</script>

This code will only be for tracking web pages, not for tracking app usage. However, gtag has been confirmed to support Google Optimize. Google Optimize is currently deployed by amending the analytics.js tag, and will work similarly.

What can we speculate about gtag.js?

Interestingly, although the code above is a Google Analytics tag, it references Google Tag Manager, so may be able to be used to better tie together Google’s tracking and tag management products.

In this article there is advice to use Tag Assistant to debug the implementation of gtag.js. This suggests that Tag Assistant already has capability to read and understand if gtag.js works correctly.

Looking at Cross Domain Tracking with gtag.js we can infer that it works similarly to cross domain tracking with analytics.js as the same filters and referral exclusions are referenced. Similarly, gtag.js still allows for content grouping via tracking code.

Event Tracking seems to be more powerful than before. There is an example here of tracking outbound links with gtag.js which was possible with analytics.js, but only via correct GTM implementation or good developer knowledge. This kind of event tracking being made more “standard” hints at more common streamlined event tracking via gtag.js.

Should I migrate to gtag.js? What about my data? Will it change?

Google has stated that moving to gtag.js will not affect your data. This is true in priniciple. However, I still suggest creating a migration plan, so that all old code is replaced.

As for “should I migrate now?”, I would suggest doing this on a staging website to ensure everything works as expected before migrating your entire code across, or waiting until gtag.js is confirmed to be out of beta. However, it is best to know that this change will come and be prepared to migrate to gtag.js in the future.

via GIPHY

We published this a long time ago…

Some of the content in this post might be out of date, and some images and links may no longer work.

Discover who we are and how we may be able to help you today:

Learn more

Share this

  • Email
  • WhatsApp
  • LinkedIn
  • Facebook
  • X (Twitter)

More insights

AI isn’t going to take your job (unless you really want it to) 
Blog

AI isn’t going to take your job (unless you really want it to) 

By Edit | 18 Jun 2024
Customer relationship marketing: How generative AI is revolutionising engagement  
Blog

Customer relationship marketing: How generative AI is revolutionising engagement  

By Edit | 4 Apr 2024
Personalisation as a process
Blog

Personalisation as a process

By Edit | 8 Mar 2024
  • Privacy policy
  • Cookie policy
  • Ts&Cs
  • Report a concern

© 2025 Edit, part of Salocin Group Ltd. All rights reserved. Company no.: 0362​4881. VAT no.: 4208​34911.

Salocin Group Certified B Corporation | Cyber Essentials Certified | British Assessment Bureau, ISO 27001 Information Security Management
Salocin Group
Your cookie preferences

We use cookies to ensure this website functions properly, to analyse website traffic and for marketing purposes.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}