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

Install the global site tag (gtag.js)

Get the tag from a product

You can find the global site tag for a specific product by clicking one of the following links. Each product generates a global site tag that you can copy and paste into the pages of your website:

Add the tag to your website

You should place the global site tag immediately after the opening <head> HTML tag on every page of your website. For example, you would add the global site tag to the following spot in the source code if this were your web page:

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Your tag goes here -->
    
    <title>The title of the page</title>
</head>
<body>
    <!-- The part of your site that's shown to users -->
</body>
</html>

Add products to your tag

Each page should have only one global site tag. Don’t copy and paste a new global site tag for each additional product, as this can lead to performance issues and make code more difficult to maintain.

If you already have the global site tag installed for one product, you can include config() lines to add more 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>

For more information about how to manage data for multiple products, see Group and route data.

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>