Getting Started

How to set up GTM for GA4 (the right way)

Step-by-step guide to configuring Google Tag Manager with Google Analytics 4. Learn the new Google Tag setup, event tracking, and best practices.

A
Antoine
January 14, 20267 min read

If you're doing anything beyond basic pageview tracking in GA4, you need Google Tag Manager. It gives you control over what gets tracked and when, without touching your site's code.

Let me walk you through the , including the recent changes to how GTM handles GA4.

What changed: GA4 Configuration Tag → Google Tag

If you set up GTM before 2024, you probably used a "GA4 Configuration" tag. That's been renamed to "Google Tag." Same functionality, different name.

Your existing tags still work. They were automatically converted. But new setups use the updated interface.

Phase 1: Setting up GTM

Create a GTM account (if you don't have one)

  1. Go to tagmanager.google.com
  2. Click Create Account
  3. Enter account name (usually your company name)
  4. Enter container name (usually your domain)
  5. Select Web as target platform
  6. Accept the terms

Install GTM on your site

You'll get two code snippets:

Snippet 1: Goes in the <head> section

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->

Snippet 2: Goes immediately after the opening <body> tag

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Replace GTM-XXXXXXX with your actual container ID.

Phase 2: Setting up the Google Tag

The Google Tag is your foundation. It initializes GA4 on every page.

Step-by-step

  1. In GTM, go to Tags → New
  2. Click Tag Configuration
  3. Select Google Tag
  4. Enter your Tag ID (your GA4 Measurement ID, starts with G-)
  5. Under Triggering, select Initialization - All Pages
  6. Name your tag (e.g., "GA4 - Google Tag")
  7. Save

Why Initialization trigger?

The Initialization trigger fires before other triggers, ensuring:

  • GA4 is ready before events fire
  • UTM parameters are captured properly
  • No events get lost during page load

Some guides use "All Pages" which works, but Initialization is cleaner.

Find your Measurement ID

If you don't know your GA4 Measurement ID:

  1. Go to GA4 → Admin → Data Streams
  2. Click your web stream
  3. Copy the Measurement ID (format: G-XXXXXXXXXX)

Phase 3: Setting up GA4 Event Tags

Now let's track specific actions.

Basic event tag structure

For each action you want to track:

  1. Go to Tags → New
  2. Select Google Analytics: GA4 Event
  3. Enter your Measurement ID (or use a , see below)
  4. Enter the event name
  5. Add event parameters if needed
  6. Set the appropriate trigger
  7. Save

Pro tip: Use a variable for Measurement ID

Instead of typing your Measurement ID in every tag:

  1. Go to Variables → User-Defined Variables → New
  2. Select Constant
  3. Enter your Measurement ID
  4. Name it "GA4 - Measurement ID"

Now use {{GA4 - Measurement ID}} in all your event tags. If you ever need to change it, update one place.

Example: Tracking button clicks

Let's track clicks on a CTA button.

Step 1: Enable click variables

  1. Go to Variables → Configure
  2. Enable under Built-In Variables:
    • Click Element
    • Click Classes
    • Click ID
    • Click URL
    • Click Text

Step 2: Create the trigger

  1. Go to Triggers → New
  2. Select Click - All Elements
  3. Configure:
    • Trigger fires on: Some Clicks
    • Click Classes contains cta-button (or whatever class your button uses)
  4. Name it "Trigger - CTA Button Click"
  5. Save

Step 3: Create the event tag

  1. Go to Tags → New
  2. Select Google Analytics: GA4 Event
  3. Configure:
    • Measurement ID: {{GA4 - Measurement ID}}
    • Event Name: cta_click
    • Event Parameters:
      • Parameter Name: button_text / Value: {{Click Text}}
      • Parameter Name: page_path / Value: {{Page Path}}
  4. Trigger: "Trigger - CTA Button Click"
  5. Name it "GA4 - CTA Click Event"
  6. Save

Example: Tracking form submissions

Method 1: Form submission trigger

If your forms do a traditional submit:

  1. Create trigger: Form Submission
  2. Configure:
    • Wait for Tags
    • Check Validation (optional)
    • Trigger fires on forms where Form ID equals contact-form
  3. Create GA4 Event tag with event name form_submit

Method 2: Success page trigger

If your forms redirect to a thank-you page:

  1. Create trigger: Page View
  2. Configure:
    • Page Path contains /thank-you
  3. Create GA4 Event tag with event name form_submit

Method 3: Custom event (Ajax forms)

For modern forms that don't reload:

  1. Add to your form success handler:
dataLayer.push({
  'event': 'form_submit',
  'form_name': 'contact'
});
  1. Create trigger: Custom Event

    • Event name: form_submit
  2. Create GA4 Event tag using this trigger

Settings Variables (new feature)

GTM now has Settings Variables to avoid repeating configurations.

Google Tag: Event Settings Variable

Good for parameters you want on every event:

  1. Go to Variables → New
  2. Select Google Tag: Event Settings
  3. Add common parameters:
    • page_location: {{Page URL}}
    • page_title: {{Page Title}}
  4. Name it "GA4 - Event Settings"

Then reference this variable in your GA4 Event tags under Shared event settings.

Testing your setup

GTM Preview Mode

  1. Click Preview in GTM (top right)
  2. Enter your website URL
  3. Your site opens with the debug panel

In the debug panel:

  • Left side shows all events fired
  • Click an event to see which tags fired
  • Check tag details to verify parameters

GA4 DebugView

  1. While in Preview Mode, go to GA4 → Admin → DebugView
  2. Perform actions on your site
  3. Watch events appear in real-time

Important: Preview Mode automatically enables GA4 DebugView. If you're not in Preview, install the GA Debugger extension.

Publishing your changes

Nothing goes live until you publish.

  1. Click Submit (top right)
  2. Enter a version name (e.g., "Added form tracking")
  3. Click Publish

Best practice: Version naming

Use descriptive version names:

  • "Initial GA4 setup"
  • "Added CTA click tracking"
  • "Fixed form submission trigger"

You can always revert to previous versions if something breaks.

Common mistakes to avoid

Double tagging

Don't install GA4 via GTM AND via direct code. Pick one.

Using All Pages instead of Initialization

For the Google Tag, use Initialization trigger. It fires first, ensuring GA4 is ready.

Not testing before publishing

Always use Preview Mode. A broken tag can stop all tracking.

Hardcoding values that change

Use variables for anything that might change, like Measurement ID, domain names, etc.

Too many tags

Each tag adds load time. Consolidate where possible. One well-configured event with parameters beats five separate events.

Organization tips

Use folders

Group related tags, triggers, and variables:

  • /GA4 - Tags/
  • /GA4 - Triggers/
  • /Third Party/

Naming conventions

Be consistent:

  • Tags: GA4 - [Event Name]
  • Triggers: Trigger - [Description]
  • Variables: [Type] - [Description]

Document your setup

Use the Notes field in each tag to explain what it does and why.

What's next?

Once GTM is configured:

  1. Set up your key events
  2. Configure e-commerce tracking if applicable
  3. Test that everything works

If you're managing multiple properties and want a simpler way to see your data, try Analayer. We turn your GA4 data into dashboards that actually make sense.

See your analytics clearly

Stop struggling with Google Analytics. Connect your account and get a cleaner, simpler view of your data in seconds.