The global site tag (gtag.js) is now the Google tag. Learn more

Add a tag to your website

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

The Google tag and Google Tag Manager provide different ways to set up and manage tags on a website. You're free to choose the option that best suits your needs since they're built using the same technology.

This article provides instructions on how to add each option to your site; however, you only need to add one of them. Choose from the following to see the information for the tag you want to add:

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>