The Google tag and Tag Manager

Stay organized with collections Save and categorize content based on your preferences.

This document provides an overview of the Google tag (gtag.js) and Tag Manager and when to use one over the other one on a website. If you are setting up Google Analytics on an app, also see the Firebase documentation.

Overview

The Google tag (gtag.js) and Tag Manager provide two different, fully supported methods to collect data from a website and send the data to Google advertisement and measurement products like Google Analytics.

The Google tag (gtag.js)

The Google tag is a single snippet of code that you paste in the <head> tag on each page of your website HTML code. The Google tag uses a JavaScript library called gtag.js. When you want to collect additional data from your website, you must change the JavaScript in your website code. Learn more about the Google tag

Google Tag Manager

Google Tag Manager is a tag management system by Google. To use Tag Manager, you need to add two snippets of code to your website HTML code — one in the <head> HTML tag and one at the top of the <body> HTML tag.

Once you add the two snippets on each page of your website, you can use the Tag Manager interface (rather than changing the JavaScript on your website) to collect additional data from your website. Learn more about Google Tag Manager

Differences between gtag.js and Tag Manager

Consider using Tag Manager if you need:

  • The ability to deploy and modify both Google and 3rd party tags
  • The ability to deploy and modify tags for both web and mobile apps
  • The ability to deploy and modify tags on the fly from a web interface
  • Collaboration and versioning capabilities

Consider using gtag.js if you are unable to use Tag Manager, or the following capabilities are important to you:

  • The ability to install tags directly on your site, without the ramp-up time of setting up a tag management system
  • The ability to work with your tags directly in JavaScript without being required to work with a separate interface

Next steps