Skip to content

Guide 100 · Container · GA4 + Tag Manager

Install the Tag Manager container snippet: one block high in the head, one right after the body tag

Checked 11 November 2026 · Verification: container fragment validated structurally (11 checks, all passed) · Steps traced to Tag Manager Help, opened 11 November 2026 · 6-minute read

A Tag Manager container does nothing until its snippet is on the site, and the snippet is two blocks, not one. The first block is a loader script that goes as high in the head tag as possible. The second is a noscript iframe that goes immediately after the opening body tag, for visitors with JavaScript off. Both blocks carry the same container ID, and both go on every page of the website. Google's install page spells out the placement for each block and shows the sample code with the placeholder ID GTM-ABCDEFGH.

Expected signal

After step 5, Tag Assistant's Test step loads the site and reports the container present. A page with only the head block still loads the container; a page with neither block loads nothing at all.

Download the container fragment: the snippet-check container fragment (JSON) (export format version 2, 930 bytes, MD5 9aa2243835ce83c0592a9677acb9bbb5). It holds the Google tag on the Initialization trigger — the first tag that only fires once the snippet is in place. The Measurement ID is left as G-XXXXXXXXXX for you to replace. The file is a hand-built import template, validated structurally — it was not exported from a live container.

What you need

  • A Tag Manager account and container already created. This guide starts where the account and container guide ends.
  • Access to the code for the website. The snippets go into the site's templates, so a developer or a theme editor with template access is needed. Google lists this as a prerequisite.
  • Your container ID. It starts with GTM- and sits at the top of the Workspace tab. Both blocks must carry this exact ID.

The trace

  1. Go to tagmanager.google.com, sign in, and open the container. Opening the container needs a Google sign-in, so this step was traced to Google's documentation, not run here.
  2. In the Workspace tab, click the container ID. The ID starts with GTM-. Clicking it opens the Install Google Tag Manager dialog with the two code blocks.
  3. Copy the first block and paste it as high in the head tag as possible. The block is the loader script: it creates the data layer, pushes a gtm.start event, and loads gtm.js with your container ID. In Google's sample it runs to 419 characters with the placeholder ID GTM-ABCDEFGH; your copy is the same length once the placeholder is swapped for your own ID. Paste it on every page, right after the opening <head> tag and above anything else you can move.
  4. Copy the second block and paste it immediately after the opening body tag. The block is the noscript iframe pointing at ns.html with the same container ID. In Google's sample it runs to 243 characters. It only matters when JavaScript is off, and it only works when it sits immediately after <body> — anywhere lower and the page may render before it runs.
  5. Repeat on every page, then test. Both blocks go on each page of the website. A site with 40 pages needs 40 head blocks and 40 body blocks — 40 × 2 = 80 snippet placements. Enter the site's URL in the dialog and click Test; Tag Assistant loads the site and reports whether the container is present. Click OK to close the dialog.

Dead ends

DEAD END — PASTING ONLY THE HEAD BLOCK. The head block alone loads the container for JavaScript visitors, so the install looks finished. Visitors with JavaScript off send nothing, because the noscript iframe is the only part that runs for them. Both blocks are the install.

DEAD END — PASTING THE HEAD BLOCK LOW IN THE HEAD. The loader must sit as high in the head as possible so the data layer exists before other scripts run. A loader pasted after a heavy script or a stylesheet can fire after the events it was meant to catch, and early data layer pushes get missed.

DEAD END — TWO DIFFERENT CONTAINER IDS. Copying the head block from one container and the body block from another leaves the site half-wired to each. The noscript iframe must carry the same GTM- ID as the loader, or the no-JavaScript traffic lands in a different container from the rest.

End state

Two blocks on every page, one ID in both, tested with Tag Assistant. The container now loads on the site; the workspace is still empty of tags, so nothing is measured yet. The next job is the Google tag, which is the GA4 install guide — it is the only live guide outside this wave this section links to.

Sources

Checked 11 November 2026. The click paths above are the ones in Google's help pages, opened 11 November 2026. No step in this guide was run inside a live Analytics property or a live Tag Manager container, because both need a Google sign-in and this site does not sign in as anyone. The container file was validated structurally instead: export format version 2, every tag's firing trigger resolves, every variable the tags reference exists in the file, and the tag types are the documented ones. Google moves menu items without warning; if a path on this page no longer matches, the linked help page is the current map. The container fragment for this guide is 930 bytes (0.91 KB, 0.45% of the reported 200 KB container size limit), MD5 9aa2243835ce83c0592a9677acb9bbb5, and passed 11 structural checks.