Google Tag Manager: what it is and how to install it on your site

Published by the UTM Builder team at Limner.

Google Tag Manager (GTM) is where you set up your site’s tags: GA4, Google Ads, the Meta pixel and others. You install the GTM code once and, from then on, add and change tags in the interface, without editing your site’s code for every change.

Container, tags, triggers and variables

GTM and GA4 aren’t the same thing

GA4 is the Google Analytics property, where the data arrives. GTM is the tool that puts tags on your site, and one of them can be the Google tag with your GA4 ID, which starts with G-. Neither replaces the other: GTM is one way to install GA4.

The other way is to paste the Google tag (gtag.js) directly into your code. The difference, according to Google: gtag.js requires writing code and only sends data to Google products; GTM also sends data to third-party and custom tags, without editing code. If GTM is already on the site, you don’t need to install gtag.js separately.

How to create the account and container

  1. Go to https://tagmanager.google.com and sign in with your Google Account.
  2. In the Accounts tab, click Create Account.
  3. Name the account and choose the country.
  4. Under Container Setup, use the site’s main address as the name and choose the Web type.
  5. Click Create and accept the Terms of Service.

The account is the company level. The container is the site. For another site, create another container in the same account.

Where to paste the two code snippets

In the Workspace tab, click the container ID. The Install Google Tag Manager dialog shows two blocks of code, which go on every page of the site:

In the same dialog, enter your site’s address and click Test to check the installation. If the site is built on WordPress, Shopify, Wix or another website builder, Google recommends the platform’s integration, which saves you from editing the code on every page.

If the site uses a dataLayer, declare it before the container snippet, high in the code, and afterward only add data with dataLayer.push:

window.dataLayer = window.dataLayer || [];

How to add GA4 inside GTM

  1. In GA4, under Admin, Data collection and modification, Data streams, open the site’s stream and copy the ID that starts with G-.
  2. In GTM, create a new tag of type Google Tag and paste the ID into Tag ID.
  3. Under Triggering, choose Initialization - All Pages.

How to test in preview mode (Tag Assistant)

  1. In the Workspace tab, click Preview at the top right. Tag Assistant opens in a new tab.
  2. Enter your site’s address and click Connect. The site opens and shows as Connected in the bottom right corner.
  3. Go back to the Tag Assistant tab, click Continue and browse the site. The screen shows which tags fired, in what order and what data they sent.

Preview mode runs the container draft as if it were published, only in the browser where you turned it on. Regular visitors see nothing. If a page breaks with the debug parameter in the address, uncheck Include debug signal in the URL.

How to publish a version

  1. In the Workspace tab, click Submit at the top right.
  2. Under Submission Configuration, choose Publish and Create Version.
  3. Give the version a name and a description that says what changed.
  4. Click Publish.

Create Version, without publishing, only saves. Each version is a snapshot of the container at a point in time, and you can go back to an earlier version if something goes wrong.

Common mistakes

Official sources