The Global Site Tag – What, Why & How

Share this article...Share on Facebook
Tweet about this on Twitter
Share on LinkedIn
Email this to someone

In 2018, Google updated their tracking code from analytics.js to gtag.js (better known as the Global Site Tag). We still have companies asking us about this, especially as Google prompts more businesses to update. Below we’ll cover what it is, why it is important and how to update.

What is A Global Site Tag (gtag.js)?

Over the years, Google Analytics has released several versions of its JavaScript library, with each one introducing new features and becoming the new recommended implementation. However, this is not quite the same thing. It’s not just another analytics library – the “Global Site Tag” is designed to simplify and streamline website tagging for all Google products.

Geared towards websites that are using on-page tracking code for various tools like Google Analytics and Google Ads (AdWords), gtag.js marks a fundamental shift in the way data is collected. It is a new style of implementation where the ultimate goal is to have one centralised script tag that is capable of sending data to all of your Google tools at the same time – so you no longer need to spend time configuring tags on your site.

It is not an entirely new library for Google Analytics alone – it loads the existing analytics.js library, along with other libraries depending on what tools you configure, such as conversions.js for Google Ads.

How Does the Global Site Tag Work?

Prior to the Global Site tag, a typical website may have had the following tags installed across web pages:

  • Google Analytics pageview tracking code on every page
  • Google Analytics event tracking for certain interactions of interest
  • Google Analytics e-commerce tracking for purchases, checkout steps, and more
  • Google Ads conversion tracking for purchases or lead form completions
  • Google Ads remarketing tags for building audiences within Google Ads

That’s FIVE different script tags- Gtag.js makes this easier by providing all of these functions through one manageable tag. Therefore, you will :

  • Be able to keep Google Tags in one place within your source code
  • Simplify installation to get you up and running with Google products sooner
  • Open up opportunities to send data to multiple tools at once, rather than requiring separate actions.

For example, if you’re using Google Analytics and Google Ads, your gtag.js snippet would look like this:

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

  gtag('config', 'UA-1234567-8'); <-----[This is the Analytics part of the code]
  gtag('config', 'AW-1234567-8'); <-----[This is the Google Ads part of the code]

The gtag.js code would be placed on each page of your website. config is a command that pulls in the corresponding library for the product configured, such as analytics.js for Google Analytics or conversion.js for Google Ads.

These config commands also take care of some initial setup items like triggering a pageview hit for Google Analytics or a remarketing hit for Google Ads. You can prevent this default behaviour by updating the config line as such:

gtag('config', 'UA-66848305-11', { 'send_page_view': false });

Difference between Universal Analytics (Analytics.js) And Global Site Tag (gtag.js)

  • Universal Analytics tracking (analytics.js) only supports Google Analytics but Global Site tag (gtag.js) can support as many Google platforms as you require, e.g. Google Analytics, Google Ads or Firebase tracking.
  • Analytics.js uses trackers to send data to Google Analytics and (2) hit types to specify the types of the data. Gtag.js doesn’t use trackers to send data to Google Analytics- it sends data to Google platforms, identified by their tracking IDs set by the config command. The event names supplied to gtag.js specify the types of data being sent to Google Analytics.
  • Analytics.js and Gtag.js both use a different type of tracking parameters.
  • Unlike universal analytics tracking, Global site tag can be used for conversion tracking.
  • Global site tag can be used for remarketing as well but Universal Analytics can’t.

Note- All the usage limitations which are applied for universal analytics tracking are also applicable for global site tag, e.g the hits limit of 200,000 hits per user per day and 500 hits per session still apply.

How to Set up tracking with gtag.js

In order to install the global site tag (gtag.js) you need to follow these steps:

  • Within Google Analytics, Find your tracking ID, which you’ll use this tracking ID in the tracking code snippet.

To find the tracking ID:

  • Click Admin.
  • Select an account from the menu in the ACCOUNT column.
  • Select a property from the menu in the PROPERTY column.
  • Under PROPERTY, click Tracking Info > Tracking Code. Your tracking ID is displayed at the top of the page.
  • Copy and paste the gtag.js tracking code snippet to each web page you want to track. Add the tracking code snippet just after the <head>tag on each page.


If you need any help with setting up your Global Site Tag, or have any other questions about it, please feel free to contact

Share this article...Share on Facebook
Tweet about this on Twitter
Share on LinkedIn
Email this to someone


No comments yet.

Leave a Reply