Set up the Google tag with gtag.js

gtag.js is a single tag you can add to your website to use Google measurement and advertising products like Google Ads, Google Analytics, Campaign Manager, Display & Video 360, and Search Ads 360. Instead of managing multiple tags for different Google products, you can use the Google tag across your entire site and connect the tag to multiple destinations.

Learn more about the Google tag

Benefits

The best way to measure conversions and optimize the value of your Google marketing investment is to place tags on every page of your site. By implementing the Google tag across your site, you gain access to the following benefits:

  • Future-proof conversion measurement. Benefit from the latest features and integrations as they become available so that you are better equipped to continue measuring conversions accurately if changes occur.
  • Codeless tag management. Turn on measurement features within Google products without having to manually change the tags on your page.
  • Faster and easier integration. Streamlined, simpler implementation and integration with other Google products, such as Analytics and Google Ads.
  • More accurate conversion measurement. The Google tag helps you achieve more accurate conversion measurement when cookies are not available and recover conversions not observed today due to industry factors.

Add the Google tag to your website

To collect data with the Google tag:

  1. Open a Google product you use and access the Google tag screen. How to find your tag ID in:

  2. Copy your Google tag ID.

  3. Paste your Google tag ID in the code sample below. Place the Google tag snippet immediately after the opening <head> HTML tag on every page you want to measure.

      <!-- 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>
    

Verify the Google tag

To verify that your tag is sending data:

  1. Go to tagassistant.google.com/.
  2. Click Add domain.
  3. Enter the URL of the website you want to debug, starting with "https://" or "http://".
  4. Click Connect.

When you connect Tag Assistant to your website, check if your Google tag ID appears in the header Google tags found. If Tag Assistant doesn't recognize your tag, find debug tips in the Tag Manager help center

You can also access the tag coverage summary for an overview of your site's tagging status.

Next steps

Now that you've set up your Google tag, configure Google products and send event data.