Thanks for previewing Google's new tag documentation! This site is in public beta. (Feedback)

Install the global site tag (gtag.js)

With the global site tag (gtag.js) you’ll find it easier to send data to multiple Google products by adding code to your website. Instead of having to manage multiple tags for different products, you can use a single global site tag to send event and conversion data to your Google products.

The global site tag should appear immediately after the opening <head> HTML tag of every page on your site. Your gtag() commands won't work properly unless a global site tag appears on a given page, above where any of the gtag() commands are called.

Obtain the tag from a product

Click the links below to learn how to locate the global site tag for a product. The following products generate global site tags that can be copied and pasted into web pages:

Add additional products to your tag

If you already have a product installed with a global site tag, use additional config() lines to add additional products.

Use the following example to learn how to add multiple products to an existing global site tag.

<!-- Global site tag (gtag.js) - Floodlight -->
<script async src="https://www.googletagmanager.com/gtag/js?id=DC-ZZZZZZ"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'G-XXXXXX');
  gtag('config', 'AW-YYYYYY');
  gtag('config', 'DC-ZZZZZZ');
</script>

Read the guide on how to group and route data for further details on how to manage data for multiple product configurations.

Create your own tag

Alternatively, you can construct your own tag. Select a product tab below, copy the code, and place it so that it appears immediately after the <head> tag on every page of your website. _Replace the G-XXXXXX, AW-YYYYYY, and DC-ZZZZZZ placeholders with the appropriate product IDs.

Google Analytics

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

  gtag('config', 'G-XXXXXX');
</script>
<!-- Global site tag (gtag.js) - Google Ads: CONVERSION_ID -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-YYYYYY"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'AW-YYYYYY');
</script>

Floodlight

<!-- Global site tag (gtag.js) - Floodlight -->
<script async src="https://www.googletagmanager.com/gtag/js?id=DC-ZZZZZZ"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'DC-ZZZZZZ');
</script>