Install Google Tag Manager for web pages

About Tag Manager

Google Tag Manager is a tag management system that allows you to update tags on your website quickly and easily. Tag Manager installation for web requires a small piece of code that you add to your web pages. This code enables Tag Manager to fire tags by inserting tags into web pages.

Before you begin

Create a Google Tag Manager account and container. Learn more

Standard web page installation

In most cases, the easiest way to get started is to find the code and instructions from within Tag Manager.

  1. In Google Tag Manager, click Workspace.
  2. Click your container ID (formatted as GTM-XXXXXX) at the top of the window to launch the Install Tag Manager window
  3. Install the tag on every page of your website using the instructions provided.
    The first code block is best placed immediately after the web page's opening <head> tag, or as high in the <head> as possible. This helps to ensure that your Tag Manager configuration is available and ready when the rest of the page loads.
    Tag Manager installation screen
  4. Optional, but recommended: Install a data layer object. A data layer will enable more robust measurement for your tag configurations.
  5. Publish your container.

Once your Tag Manager installation is complete, all tag configuration is performed from in Tag Manager.

Custom web installations

In rare cases (e.g. when creating a new template for a content management system or ecommerce template), you may wish to code a custom gtm.js tag. Add the following code so that it is as close to the opening <head> tag as possible on every page of your website. Replace GTM-XXXXXX with your container ID:

<!-- Google Tag Manager -->
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
<!-- End Google Tag Manager -->

Next, add this code immediately after the opening <body> element on every page of your website. Replace GTM-XXXXXX with your container ID:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src=""
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Get product-specific setup guidance

Click the links below to learn how to setup Tag Manager for specific products: