This page provides an overview of the Google
tag, Google Tag
Manager, and gtag.js
, and
explains how to use them to set up tagging on your website. If you're setting up
Google Analytics on an app, see Set up app
measurement.
The Google tag
The Google tag is a single tag you can add to your website to measure website and ads performance. You must use the Google tag to send data to Google Ads and Google Analytics 4 (GA4). The accounts you send Google tag data to are also called destinations.
The Google tag is the basis for all measurement use cases. If you use Google Ads or GA4, the product auto-generates a Google tag for you.
Here are some benefits of using the Google tag:
- Use a single Google tag across your entire website instead of managing multiple tags for different Google product accounts.
- Automatically measure page views, clicks, scrolls, and more in Google Analytics.
- Automatically measure conversions and campaign performance in Google Ads.
- Configure Google tag settings from within your Google products (for example, Google Ads, Google Analytics, Google Tag Manager), minimizing the need to make code changes to your site.
This tagging option is great for marketers who don't have a web development team readily available or use a content management system (CMS). If you only need the default metrics, such as page views, clicks and scrolls, you can set up the Google tag once and you're all set.
Here's how to get started with the Google tag:
If you don't use a website builder or CMS: Set up the Google tag
If you need more tagging options, add Google Tag Manager
or gtag.js
to your implementation.
Google Tag Manager
Google Tag Manager is a tag management system that lets you update tags on your website or mobile app from a web interface. You can use Google Tag Manager to load a Google tag on your website instead of manually adding the Google tag code snippet to your site.
Google Tag Manager supports Google-specific tags, a wide array of third-party tags, and even custom tags. For details on the supported tag options, see all supported tags.
Google Tag Manager might be helpful for marketers who are in charge of tagging and need to manage Google and tags from other parties. It's also a good option for tag administrators and agencies, and can be used alongside site code changes.
Set up and install Tag Manager →
If you were using GA4 configuration tags, they have been automatically upgraded to the Google tag. Your measurement and capabilities haven't changed, and you don't need to take any action. Your GA4 event tags stay the same.
gtag.js
If you already use Google Tag Manager, you don't need to use gtag.js
. Google
Tag Manager fully supports Google Ads and Google Marketing Platform tags, and
you don't need to deploy additional code using gtag.js
on your site.
The Google tag uses the gtag.js
JavaScript framework to add Google tags
directly to web pages. To use gtag.js
effectively, you need to be proficient
in HTML, CSS, and JavaScript.
gtag.js
is best for web developers who are in charge of tagging and only need
to manage Google tags. gtag.js
lets you install tags directly on your web
page, without the ramp-up time of setting up a tag management system.
If your tagging needs evolve, you can migrate your tags to Google Tag Manager at a later date.
gtag.js cookie usage
For the latest information on cookie usage in Google Analytics 4, see Cookie usage on websites.
The gtag.js
JavaScript library uses
first-party cookies to do the following:
- Distinguish unique users.
- Distinguish sessions for a user.
When using the recommended JavaScript snippet, cookies are set at the highest
possible domain level. For example, if your website address is
blog.example.co.uk
, gtag.js
sets the cookie domain to .example.co.uk
.
Setting cookies on the highest level domain possible lets measurement occur
across subdomains without extra configuration.
gtag.js
sets the following cookies:
Cookie name | Default expiration time | Description |
---|---|---|
_ga |
2 years | Used to distinguish users. |
_ga_<container-id> |
2 years | Used to persist session state. |
Customization
To learn how you can customize the default cookie settings using gtag.js
, see
Cookies and user identification
guide.
Google Tag Manager versus gtag.js
The following table highlights the differences between Tag Manager and
gtag.js
.
|
Google Tag Manager (Tag Management System) |
---|---|
You need to write code to deploy tags and customize your web collection |
Deploy and modify both tags from Google and third-parties on the fly without editing code. |
Can only send data for Google products. |
Can send data for Google tags, third party tags, and custom tags. |
You need to manage your tags from within your code, and may need to duplicate code for different outlets, for example, web and app. |
Manage tags for your website and apps all from tagmanager.google.com |
Version control depends on how you manage your code. |
Collaborate with others using workspaces, and version control tags. |
Server-side tagging is possible. You still need to use Google Tag Manager to deploy and interact with your server container. |
Tag Manager helps you deploy tags on a server. If you are exploring this option, read Client-side and server-side tagging. |
Compatible with static-site generators, CMSs, website builders or manually authored HTML pages that support JavaScript. |
Compatible with many CMSs and website builders. If your system doesn't
support Tag Manager, use the Google tag ( |
Cost: Free |
Cost: Free |