Sub topic 7
Install the Google tag through Google Tag Manager
This chapter assumes you have a GA4 web data stream, its Measurement ID, and permission to edit your Google Tag Manager (GTM) container. You should also understand that a tag is code or a tracking instruction, a trigger decides when it runs, and a variable stores a reusable value.
Google Tag Manager is a web service that loads tracking tags for your site. You install the GTM container on the site once. After that, you can add or change many tags in the GTM interface without editing the site’s HTML for every change.
Understand the installation path
The data flow looks like this:
There are two separate installations:
- The GTM container snippet must be placed on the website.
- A Google tag must be created inside that container with your GA4 Measurement ID.
The container snippet does not send GA4 data by itself. The Google tag inside the container does that.
Add the GTM container to the site
In Google Tag Manager:
- Create or open a web container.
- Select the container ID, which looks like
GTM-ABC1234. - Copy both installation snippets.
- Place the first snippet as high in the page’s
<head>as possible. - Place the second snippet immediately after the opening
<body>tag. - Save and publish the website changes.
The exact snippets depend on your container, so copy them from GTM instead of copying an example from another site. The <noscript> snippet supports limited tracking when JavaScript is unavailable. It does not replace the main script.
If your site uses a content management system, the platform integration may provide fields for the GTM container ID. Follow that platform’s instructions and confirm that it adds both parts of the container installation.
Create the Google tag in GTM
Open the GTM container and create a new tag.
- Choose the Google tag tag type.
- Enter the GA4 Measurement ID, such as
G-XXXXXXXXXX. - Use the Initialization - All Pages trigger, or the recommended all-pages trigger shown by your GTM workspace.
- Save the tag with a clear name such as
Google tag - GA4. - Select Preview and test the container.
- Submit and publish the container after the preview succeeds.
The Google tag establishes the basic GA4 connection. Page views and other automatically collected events can then be sent according to your GA4 and Google tag settings.
Older GTM containers may use a GA4 Configuration tag instead. Do not create both a Google tag and a GA4 Configuration tag for the same Measurement ID unless you have a specific migration plan. Running both can send duplicate page views.
| Item | Example | Purpose |
|---|---|---|
| GTM container ID | `GTM-ABC1234` | Loads the Tag Manager container |
| Measurement ID | `G-XXXXXXXXXX` | Identifies the GA4 web data stream |
| Trigger | Initialization - All Pages | Runs the Google tag on page loads |
Configure consent before publishing
If your site requires visitor consent, configure consent behavior before the Google tag runs. In GTM, use a consent-aware setup or a consent management platform that sends the visitor’s choice to GTM. The default state must be applied before the Google tag fires.
Do not treat GTM’s container loading as proof that analytics consent was granted. The container can load while the Google tag limits storage or waits for an updated consent state.
Preview and publish safely
GTM’s Preview mode opens Tag Assistant, which shows whether the container loaded and which tags fired.
Check these items:
- The GTM container appears on the page.
- The Google tag fires once on the intended pages.
- The Measurement ID matches the correct web data stream.
- Consent states match your site’s privacy requirements.
- No second plugin or hard-coded Google tag sends the same page view.
After publishing, open GA4’s Realtime report. Use DebugView when the browser session is marked for debugging, such as through Tag Assistant. Realtime data can appear before standard reports, which may take longer to process.
Exercise
A site already has a platform plugin configured with Measurement ID G-AAA1111111. You add a GTM Google tag with the same ID, and every page view appears twice. What should you check first?
Show answer
Check whether the plugin and GTM tag both send the page_view event. Keep one primary installation, or disable duplicate page-view sending in the setup that remains.