Skip to content

Insights / Digital marketing

How to set up Google Tag Manager for GA4 and lead tracking

Set up Google Tag Manager by creating a web container, adding its installation code to the site and configuring a Google tag for your GA4 web stream. Set up consent before measurement, send lead events only after the site confirms a submission, and test the resulting events before publishing. Tag Manager controls when tags run. GA4 receives and reports the events they send.

By Published 7 min read

Create the account and install its web container

Start by checking what already runs on the site. Look in your CMS integrations, shared layout, cookie banner and existing GTM workspaces. Record each container or Google tag ID, what installed it and where it sends data. Check a landing page and the page with the form. A plugin that installed Analytics globally can overlap with a tag added during a redesign. Give the existing setup an owner before switching it off, so the migration can be tested as a single release.

  1. In Tag Manager, open Accounts and select Create Account. Enter the organisation name and the country. Under Container Setup, use the website name or main domain, select Web, choose Create and accept the terms. A web container can serve all pages of the site.
  2. From the workspace, click the ID beginning GTM- to open the installation instructions. Use the supported CMS integration or install the code shown for your container. Place the script as high in the shared HTML head as possible. If your installation uses the earlier two-part snippet, its noscript part belongs immediately after the opening body tag.
  3. Deploy the shared layout and check that the intended container appears on the relevant page templates. Include campaign pages and external form or booking pages where you control tagging. Use a company-controlled account and give named users the access needed to edit or publish.

A container installation is ready for configuration when the expected ID appears on every in-scope page and you know which integrations will continue sending data. Keep a record of that baseline for the release check.

Connect the Google tag to the GA4 web stream

Open the intended GA4 property. In Admin, under Data collection and modification, open Data streams, open the web stream and copy its measurement ID beginning G-. Back in Tag Manager, open Tags, choose New and select Google tag under Tag Configuration. Enter the ID in Tag ID. For a standard setup use Initialization - All Pages, subject to your chosen consent implementation, and save the tag with a name that identifies its destination. The GTM- identifier belongs to the container. The G- identifier here identifies the stream you want to measure.

If the container has been optimised in the newer Tag Manager interface, check the Google destination in Settings. The optimisation moves settings into the container and retains existing event tags. Check what is already configured before adding a tag for the same destination.

Send test traffic to a separate GA4 property if you need to keep it out of production reports. A different stream in the production property still feeds that property. Check that the test configuration resolves to the intended destination before running the first visit. Capture that destination alongside the container ID in the release notes. If several teams share a property, add the stream name and site to the notes so an analyst can repeat the check.

For a migration, compare one navigation before and after the change using Tag Assistant. An embedded Google tag and a GTM tag can send to the same stream. A CMS integration can also dispatch page views or events independently of the base tag. Plan the removal of the old route alongside the introduction of the new route. For sites that update their address without reloading the page, test actual route changes as well as a fresh load. Agree which mechanism sends page views and inspect both routes so a single navigation does what your measurement plan expects.

Configure Consent Mode v2 before measurement

The consent management platform, or CMP, records the visitor’s choices. Consent Mode communicates those choices to compatible Google tags. The four commonly used signals are analytics_storage for analytics storage, ad_storage for advertising storage, ad_user_data for sending ad-related user data to Google and ad_personalization for personalised advertising. Map each signal to a decision your banner actually offers and agree what applies before a visitor makes a choice.

If the CMP supplies a GTM template that writes consent, configure it according to the vendor’s instructions. Use Consent Initialization - All Pages for the consent-writing template where that integration calls for it. Set appropriate defaults before measurement and update the signals when the choice changes. A custom GTM template should use Google’s consent APIs, setDefaultConsentState and updateConsentState. Store the choice through your consent solution and verify that it takes effect on subsequent pages.

Google documents two implementations. In basic mode, Google measurement tags are blocked until the required consent is granted. The banner must be available while those tags are blocked. In advanced mode, supported tags load with consent defaults and can send cookieless pings when storage is denied. Choose the implementation with the person responsible for privacy and configure other tags separately. Built-in consent checks on supported Google tags control their behaviour. A third-party tag may require additional consent checks or a trigger that respects the banner choice.

Test a fresh visit, rejection, partial acceptance, full acceptance and a later withdrawal. Tag Assistant should show the default before measurement and the update when a preference changes. Repeat the test after navigating to a new page.

If basic mode prevents Tag Assistant from connecting before consent, confirm the block in a fresh session and reconnect after granting permission for the test.

Send different events for clicks and accepted forms

Decide which actions you want to diagnose and which mean a lead reached the business. A phone-link click can show interest. A form becomes a lead when the application has accepted it under the agreed business rule. A button click can happen before validation and can repeat during a retry. Use events with distinct names and give each a condition someone can test.

User actionTrigger to configureExample GA4 event
Clicks a phone linkJust Links, limited to Click URL beginning tel:phone_link_click
Opens a contact panelAll Elements, limited to a stable element identifier and relevant pagescontact_panel_open
Sends an accepted enquiryCustom Event matching the success event pushed by the applicationgenerate_lead

Enable the relevant built-in click variables for click triggers. Use an identifier that survives copy changes and test clicks on the icon and the text if both are inside the link. Review Enhanced measurement in the web stream and any CMS events before adding a second rule for the same interaction.

For a form submitted in the background, ask the developer to push a named event such as lead_accepted to dataLayer only after the application confirms acceptance. Keep the payload to allowed values such as an internal form code. In Tag Manager, add a Custom Event trigger for lead_accepted, then create a Google Analytics: GA4 Event tag with the stream’s measurement ID and the event name generate_lead. Map only the parameters needed. Keep names, email addresses, phone numbers, free text and identifying URL values out of Analytics. Try invalid fields and a failed request. Those actions should leave the success event absent. GTM’s built-in Form Submission trigger can observe a browser submission. For a lead that depends on acceptance by the server, use the application’s confirmation.

Preview the workspace and verify the published version

Click Preview in the workspace, enter the page URL in Tag Assistant and select Connect. Inspect the event timeline in the order the browser ran it. Look at the consent state, the tags that fired, the tags that did not and the variables passed on each interaction. Open DebugView in the right GA4 property to inspect events and parameters from the test device when the applicable consent and debug settings permit it.

  1. Start with a fresh browser profile. Follow the banner cases and check the configured behaviour both before and after each choice.
  2. Follow a valid enquiry through to acknowledgement. Confirm one generate_lead at the expected destination. Repeat with no valid submission, a double click and a return to the confirmation page.
  3. Follow the campaign page and a normal site page. Check the installed container ID, click rules and page-view counts on each. Record which observations belong to the draft.

Use Submit in the GTM workspace after review. Select Publish and Create Version, add a name and description that capture the consent and measurement changes, review the affected items and publish to the intended environment with a user who has permission. Open a fresh session without Preview and repeat the essential tests. If a release needs to be reversed, select and publish a previously verified version from Versions. Check separately for related CMS or website changes, since version history applies to the container. Record the version and the production checks for the next person who changes the setup.

Frequently asked questions

Is Tag Manager the same as Google Analytics?
Tag Manager deploys tags and sets their firing rules. Google Analytics processes events and presents reports.
Where do I paste the installation code?
Put the script supplied for the container high in the shared HTML head. If Google provides a two-part installation, put the noscript block immediately after the opening body tag.
Why is GA4 receiving two events for one action?
Look for two paths sending the same event. Compare the CMS integration, embedded scripts, Enhanced measurement and GTM triggers using one controlled test.
Does Preview publish the changes?
Preview loads the GTM draft for testing in the connected session. Use Submit, then Publish and Create Version, to release the approved workspace changes.

Sources

  1. Google, create an account and container
  2. Google, install a web container
  3. Google, configure the Google tag in GTM
  4. Google for Developers, website consent mode
  5. Google for Developers, basic and advanced consent mode
  6. Google, test consent with Tag Assistant
  7. Google for Developers, the data layer
  8. Google, click trigger
  9. Google, GA4 event tags
  10. Google Analytics, enhanced measurement
  11. Google Analytics, avoid sending identifying information
  12. Google Analytics, verify events in DebugView
  13. Google, preview and debug a container
  14. Google, publishing and versions
  15. Google for Developers, generate_lead
  16. Google Analytics, find the measurement ID
  17. Google, form submission trigger
  18. Google Tag Manager Help — interface and container updates
  19. Google Analytics Help — account, property and data stream structure

New business

Have a project in mind?

Send a short note about your goal and where you need help. A senior member of the team will reply within one business day to arrange an initial call.

contact@wmktechnologies.com