Skip to content
Faisal Mahmud TusherDigital marketing, SEO & analytics
with Faisal Tusher

Marketing Analytics › Google Tag Manager

GA4 Through GTM

A step-by-step tutorial installing GA4 with Tag Manager: the Google tag, configuration settings, event tags, user properties, consent, preview and publishing.
Tutorialbeginner9 min readUpdated

Before you start

  • A GA4 property and its measurement ID: the identifier beginning with G- shown on the web data stream's details page. The GA4 setup tutorial covers creating the property, the stream and the settings that live on the GA4 side.
  • A container installed on every template with edit and publish rights for you, or edit rights plus someone who can publish. The containers guide in the Tag Manager hub covers installation.
  • The tracking plan, listing each event, its parameters and the user properties the business wants, since every tag below is built from a line of it. The GA4 events guide explains which events GA4 collects on its own and which you must send.
  • Data layer pushes for the planned events, agreed with developers and live at least on a staging site. The data layer guide gives the contract format.
  • Familiarity with tags, triggers and variables, from the building blocks guide, which this tutorial assumes.
  • A decision on consent: whether a consent platform sets defaults in the container, and which tags must wait for consent. The consent mode guide covers the implementation; here you only wire the checks.
  • No direct gtag.js snippet on the page, or a plan to remove it when the container version goes live, so that page views are not counted twice.
  1. Create the Google tag

    In the workspace, add a new tag and choose the Google tag type. Paste the measurement ID into the tag ID field, or better, reference a constant variable that holds it so the ID is defined once in the container. This tag loads the measurement library, sets the configuration every event will share, and sends the automatic page view unless told not to. For its trigger, use the initialisation trigger on all pages rather than the ordinary page view trigger: initialisation fires earlier in the page load sequence, which is what Google recommends so that the Google tag has run before any event tag can fire. Name the tag so its purpose is obvious in a list, for example with a prefix naming the product and the property it belongs to, and leave the configuration section for the next step.

  2. Set the configuration settings

    Open the Google tag's configuration settings. Configuration parameters are key-value pairs applied when the library loads. The two you will most often set are send_page_view, which you set to false only when the site sends its own page view events, as a single-page application typically does, and user_id, which you set from a data layer variable when the site identifies logged-in visitors. Rather than typing parameters into the tag, create a configuration settings variable, add the parameters there and reference it from the tag; a second property or a second container can then reuse the same configuration. The shared event settings section below it takes an event settings variable, which carries parameters and user properties that should accompany every event, and you will fill that in during the user properties step. Whether to send a user ID at all, which value to use and when to clear it are decisions the guide to User-ID and signed-in users in GA4 sets out.

  3. Build an event tag with parameters

    Add a tag of the GA4 event type. Set its measurement ID to the same constant the Google tag uses, and type the event name exactly as the tracking plan and the data layer push spell it, such as generate_lead. In the event parameters table, add each parameter the plan lists, with its value read from a data layer variable named after the matching key, so that form_name in the push becomes form_name in the event without translation. For an e-commerce event, open more settings and switch on sending e-commerce data from the data layer, which reads the ecommerce object the site pushed. The trigger is a custom event trigger whose event name matches the push. Repeat for each planned event, or build one generic tag that reads the event name from the built-in event variable and attach it to a pattern-matching trigger, as the building blocks guide describes under patterns.

  4. Add user properties

    User properties describe the person rather than the action: a customer tier, a subscription plan, a logged-in state. They are set in the user properties table of an event tag or, for properties that should accompany every event, in the event settings variable referenced from the Google tag's shared event settings. Each is a name and a value, with the value usually read from a data layer variable that the site pushes as context before the container loads. Keep the names in snake_case and within GA4's documented limits on count and length, which the Analytics Help pages list. Two things are not user properties: the user ID, which is a configuration parameter set in the previous step, and anything that identifies a person directly, which GA4's terms prohibit sending. A user property set once persists for that user's later events, so it is enough to send it when the value is known rather than on every push.

  5. Set consent settings on each tag

    Open the advanced settings of the Google tag and of each event tag and expand the consent settings. The panel shows the built-in consent checks for the tag type: Google's tags read the analytics and advertising storage signals on their own and adjust what they send accordingly. Below that is the additional consent section, which you set to require no additional consent when the built-in behaviour is what you want, or to require specific consent types when the business has decided a tag must not fire at all until those are granted. Whichever you choose, the defaults themselves are set by the consent platform's tag on the consent initialisation trigger, before any of these tags runs. The consent mode guide explains the signal types, the difference between basic and advanced implementations and how to verify what each tag received. For this tutorial the requirement is only that no analytics tag is configured to ignore the signals.

  6. Preview the container

    Start preview mode from the workspace and connect it to the site, which opens the site in a tab linked to the Tag Assistant debugger. Load a page and read the summary: the Google tag should appear as fired on the initialisation event, and the GA4 page view should show in the tags fired list. Then perform each action in the tracking plan, submitting a form, adding an item, playing a video, and for each one find the data layer message it produced, confirm the custom event trigger matched it, open the tag that fired and check that every parameter holds the value the push carried rather than undefined or an empty string. Any mismatch is either a key name that differs between the push and the variable or a push that arrived too late. The debugging tutorial walks through every tab of the debugger in detail; here the goal is one clean pass through the plan.

  7. Publish with a version note

    Submit the workspace. Choose to publish and create a version, give the version a name that says what it contains, and write a description listing the tags, triggers and variables added, in enough detail that someone rolling back next month understands what they would be removing. If the business requires review before release, create the version without publishing and ask the person with publish rights to release it; the approve and publish permissions exist precisely to separate building from releasing. Once published, confirm the live version number on the container overview, and if the site previously carried a direct GA4 snippet in its templates, this is the moment the developers remove it, in the same release window, so that there is no period in which page views are counted twice.

  8. Verify in DebugView

    In the GA4 property, open DebugView under admin. While preview mode is running, the container marks its hits as debug traffic, so your own session appears in DebugView as a device with a stream of events in order. Click through the plan once more and watch each event arrive, opening it to check the parameters and user properties attached. This is the first point at which GA4's own processing is visible: a parameter that is present here but absent from reports later needs registering as a custom definition, and a key event that is not counting as a conversion needs marking in the property, both of which are GA4-side tasks the setup tutorial covers. Once the preview session is closed, verify from a normal browser that the realtime report shows your visit with one page view per page, and that the conversion rate (CVR) the business reads now has a denominator and a numerator that both come from this container.

Tag reference table

The finished container for a lead-generation site, before any ad platform tags are added, looks like this.

TagTypeTriggerKey fieldsNotes
Google tagGoogle tagInitialisation, all pagesTag ID from a constant; configuration settings variable; shared event settings variableSends the automatic page view unless send_page_view is false
GA4 event: generate_leadGA4 eventCustom event generate_leadEvent name; form_name and form_location parameters from data layer variablesPushed by the site after server-side confirmation, not on click
GA4 event: sign_upGA4 eventCustom event sign_upEvent name; method parameterUser property for plan tier set in the same tag
GA4 event: file_downloadGA4 eventCustom event file_downloadEvent name; file_name parameterOnly if enhanced measurement's own download tracking is switched off
GA4 event: page view (single-page app only)GA4 eventCustom event page_view pushed by the routerEvent name; page_location, page_titleRequires send_page_view false on the Google tag
Constant: measurement IDVariable—The G- identifierReferenced by every GA4 tag
Event settingsVariable—Shared parameters and user propertiesReferenced from the Google tag's shared event settings
Internal trafficTrigger exceptionMatches office IP range or a debug cookie—Attached to every tag that sends data
Illustrative example — not a real result

A software company's first week on GA4 through the container

A project-management tool with a marketing site and a logged-in app installs GA4 through one container. The plan has 7 events: three forms (generate_lead for the demo request, sign_up for trial starts, and a newsletter event), two content events, and two in-app milestones pushed by the product. The Google tag runs on initialisation with send_page_view left true on the marketing site; the app, a single-page application, sets it false and pushes its own page_view on each route. Preview finds one fault: the trial form fires sign_up on the submit click, so 23 of the first 140 trial events in DebugView have no plan user property because validation failed and no account existed. The push is moved to the server confirmation. In the first full week the property records 1,912 marketing page views, 96 demo requests and 117 trial starts, and the CRM shows 95 and 117 respectively, close enough that the team retires the spreadsheet it had been keeping.

Common mistakes

  • Two Google tags for one property. The direct snippet left in the template plus the container tag, doubling every page view. Remove one in the same release.
  • Google tag on the page view trigger. It usually works, until an event tag fires first on a fast page. Use the initialisation trigger as Google recommends.
  • Event names that differ by a character. The push says generate_lead, the trigger says generateLead. Copy names from the tracking plan, never retype them.
  • Parameters sent but never registered. They appear in DebugView and nowhere else. Register custom definitions in the property, which the GA4 events guide covers.
  • Measurement ID typed into every tag. One typo in one tag sends a quarter of events to nowhere. Use a constant variable.
  • Consent panel never opened. Tags fire regardless of the banner because nobody checked what the defaults were. Open the consent settings on every tag.
  • Publishing from the change list. The list looked complete; the trigger matched nothing. Preview every event, following the debugging tutorial, before the version goes live, and keep the push shapes in the data layer guide's contract format so the next event is as easy as the first.

Frequently asked questions

Do I still need the gtag.js snippet on the page if GA4 runs through Tag Manager?

No, and keeping it causes double counting. The Google tag inside the container loads the same measurement library and sends the same page views, so a site that carries both the direct snippet and the container tag reports two page views for every one visit. Remove the direct snippet from the templates when the container version goes live, and check in DebugView that each page load produces one page view.

Should every GA4 event be its own tag?

Either approach works and the choice is about readability. One tag per event is explicit and easy for a reviewer to follow but grows with the plan; a single generic tag that reads the event name from the data layer is compact but hides the list of events behind a pattern. Small containers usually start with one tag per event and consolidate later, once the parameters have settled into an event settings variable.

Why do events show in preview but not in GA4 reports?

Standard reports lag by many hours, so the first place to look is DebugView and the realtime report, which show events within seconds. If the events appear there, the tags work and the reports will catch up; if they do not, the tag fired but the request was blocked or misaddressed, which the browser's network view will show. A parameter missing from a report is a different problem: it needs to be registered as a custom definition in the property first.

Terms used on this page

Where this page is used

Also related

Sources

  1. Google Tag Manager Help — Google Tag Manager Help
  2. Google Analytics Help — Google Analytics Help

Related