Skip to content

Guide 132 · Setup · GA4 + Tag Manager

Install the Google tag with gtag.js: the snippet that goes right after the opening head tag

Checked 11 November 2026 · Verification: snippet structure checked (2 script blocks; config sends page_view; 24–48 hour report lag) · Steps traced to Analytics Help, read 11 November 2026 · 6-minute read

The Google tag installed by hand is two script blocks, pasted once per page, right after the opening head tag. The first loads the gtag.js library; the second configures it with the Measurement ID, and that configuration sends a page_view on its own. This guide copies the snippet from the stream's own installation instructions, so the ID in it is the one Google generated for the property.

Expected signal

After step 4, every page of the site carries the snippet, and a visit shows in the Realtime report within minutes. Standard reports take 24 to 48 hours.

Download the reference: the gtag.js install reference (JSON) (939 bytes, MD5 4710d7087175dde0f51f296cdc9ee973). The snippet structure from Google's tag ID page: 2 script blocks, the config call sending page_view, and the 24–48 hour standard-report lag.

What you need

  • A GA4 property with a web data stream. The snippet is generated from the stream, so the stream must exist first.
  • The Editor role or above at the property level. Google requires Editor or above to find the Google tag.
  • Access to edit the site's HTML on every page. The snippet must sit on every page; a page without it is invisible to the property.
  • No second install of the same tag. Use the Google tag or Tag Manager, not both — the two together double-count page views.

The trace

  1. Open the stream. In Admin, under Property Settings, click Data streams, then click the name of the web data stream.
  2. Open the tag instructions. In the Google tag section at the bottom of the Web stream details page, click View tag instructions. On the Installation instructions page, click Install manually.
  3. Copy the whole snippet. Copy the entire section of code beginning with <!-- Global tag (gtag.js) --> and ending with </script>. The snippet has 2 script blocks: the first loads gtag.js with the Measurement ID in its source address, and the second defines the gtag function, stamps the load time, and calls gtag('config', 'G-XXXXXXXXXX') with the property's own ID in place of the placeholder.
  4. Paste it after the opening head tag on every page. Place the snippet immediately after the opening <head> tag, before any other scripts. A page that misses the snippet sends no data, so a shared template or header include is the reliable place to put it — one edit covers every page the template serves.
  5. Know what the config call does. The gtag('config') call sends a page_view automatically. Do not add a second page_view call beside it; that is the manual-install version of the double-counting mistake the Tag Manager guide warns about.
  6. Confirm it in Realtime. Open the site in a browser, then open the Realtime report in the property. The visit should appear within minutes. Standard reports and explorations can take 24 to 48 hours to process data, so a same-day check belongs in Realtime, not in a standard report — the gap between 24 and 48 hours is a 24-hour window, so a report checked at hour 30 can still legitimately be empty.

Dead ends

DEAD END — PASTING THE SNIPPET IN THE BODY OR THE FOOTER. Google's installation instructions put the snippet immediately after the opening head tag. In the body or the footer it still loads, but later, and any script that depends on the tag running first can fire before it exists.

DEAD END — PASTING THE SNIPPET ON SOME PAGES ONLY. Every page without the snippet is a blind spot. The tag cannot count a page it is not on, and a template that serves half the site leaves half the traffic unmeasured.

DEAD END — RUNNING THE SNIPPET AND TAG MANAGER TOGETHER. Google's guidance is to use either the Google tag or Tag Manager, not both. Both installations load the same Measurement ID and each sends its own page_view, so the reports count every visit twice.

End state

The Google tag snippet sits immediately after the opening head tag on every page, carrying the property's own Measurement ID. Realtime shows visits within minutes of publishing, and page_view arrives once per page load.

Sources

Checked 11 November 2026. The copy path and the snippet shape above are the ones in Google's tag ID page, opened 11 November 2026. No step in this guide was run inside a live Analytics property, because that needs a Google sign-in and this site does not sign in as anyone. The reference file was checked in Python: its figures were recomputed from the documentation values and match the numbers on this page. Google moves menu items without warning; if a path on this page no longer matches, the linked help page is the current map.