gtag.js Developer Guide

The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Ads, Campaign Manager, Display & Video 360, Search Ads 360, and Google Analytics. Instead of having to manage multiple tags for different products, you can use gtag.js and more easily benefit from the latest measurement features and integrations as they become available.

gtag.js makes it easy to send data to multiple Google products by adding code to your website. There's no need to create additional accounts or manage configuration in a separate interface.

High level steps

Regardless of whether you want to send data to Google Ads, Campaign Manager, Display & Video 360, Search Ads 360, or Google Analytics, the basic model for using gtag.js is as follows:

  1. Add the global snippet to every page on your site and configure it to work with each product. Learn more
  2. Use gtag() commands to capture events and send data to one or more products (e.g. Google Ads, Google Analytics, etc.). Learn more

Once the tag has been installed, you can configure it to handle multiple configurations, all from the same gtag.js framework.

About this guide

This guide will help you get started using gtag.js for common use cases that apply across the Google Marketing Platform. Specifically, it illustrates:

  • basic configuration for gtag.js across supported products.
  • how to send event data.

For product-specific documentation related to gtag.js, refer to the following:

Google Tag Manager or gtag.js?

Google Tag Manager is a robust and full-featured tag management system, which supports Google and 3rd party tags. You can add and modify tags through the Tag Manager interface without adjusting the code on your site. Learn more

If you are already using Tag Manager, you should continue to do so. If you don't need a tag management system, it is fine to use the gtag.js tags provided by each product.

Tag Manager and gtag.js are built on the same infrastructure, and should work properly if deployed on the same page.

Next steps