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

Install the Google tag (gtag.js)

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

Get the tag from a product

You can find the Google tag snippet for a specific product by clicking one of the following links. Each product generates a Google tag that you can copy and paste into each page of your website:

Add the tag to your website

You should place the Google tag immediately after the opening <head> HTML tag on every page of your website. For example, you would add the Google 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 multiple products to your tag

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

If you already have the Google 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 Google tag.

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

  gtag('config', 'TAG_ID');
  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 from the following product tabs, copy the code, and place the code so that it appears immediately after the <head> tag on every page of your website. Replace the TAG_ID and DC-ZZZZZZ placeholders with the appropriate tag ID or product ID.

Google Analytics

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

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

  gtag('config', 'TAG_ID');
</script>

Floodlight

<!-- Google tag (gtag.js) -->
<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>