How to Set Up Google Analytics 4 in GTM
Switching to Google Analytics 4 can feel like a big leap, but setting it up with Google Tag Manager makes the process much more manageable and powerful. Using GTM gives you a central hub to control all your tracking scripts, allowing you to add and update your GA4 tracking without constantly bothering a developer. This tutorial will guide you step-by-step through adding the basics of GA4 to your website using GTM.
So, Why Should You Use GTM for GA4?
Before jumping into the "how," it's helpful to understand the "why." You can install GA4 directly on your website by pasting its tracking code into your site's header. However, using Google Tag Manager (GTM) is the industry-standard best practice for a few key reasons:
- Centralized Management: GTM acts as a toolbox for all your third-party scripts (or snippets of code), not just GA4. Facebook Pixel, Google Ads tags, and other marketing or analytics tools can all live in one organized container.
- Less Reliance on Developers: Once the GTM container is placed on your site, you can deploy and modify most tracking tags yourself. This means you can add event tracking for a new marketing campaign CTA without having to create a ticket and wait for a developer.
- Version Control & Debugging: GTM has a built-in testing environment (Preview Mode) and version control. You can safely test your changes before making them live and roll back to a previous version if you make a mistake. This is invaluable in preventing data tracking errors.
- Power and Flexibility: It gives you granular control over what you track and when. You can fire tags based on nearly any user interaction, from video views to scroll depth to form submissions, all without touching your website's code.
Simply put, GTM future-proofs your analytics setup, keeping it neat, organized, and much easier to scale as your tracking needs grow.
First Things First: Your Pre-Flight Check
To follow along with this guide, you’ll need three things ready to go:
- An activated Google Tag Manager Account: If you don’t have one, head to tagmanager.google.com and create an account. You'll be prompted to set up a "container," which is where all your website's tags will live. Give it a name related to your website.
- Your GTM container snippet installed on your website: When you create a container, GTM gives you two snippets of code. These need to be placed on every page of your site. If you're using a platform like WordPress, plugins like "GTM4WP" make this a simple copy-paste job without needing a developer. On platforms like Shopify, you can often paste these codes into your theme files. If you do need a developer, it's a one-time request.
- A Google Analytics 4 Property and Measurement ID: You need an active GA4 property to send data to. You'll find your Measurement ID inside your GA4 property's admin settings (Admin > Data Streams > Click your website stream). The ID starts with "G-" and looks something like
G-ABC123XYZ4. Copy this ID, you'll need it in a moment.
Once you have all three of these in place, you’re ready to start the setup.
Step 1: Create the GA4 Configuration Tag
The first and most important tag you need is the GA4 Configuration Tag. This is the foundation of your GA4 setup. It loads the necessary analytics script on every page of your site and establishes the connection to your GA4 property. Every other GA4 tag you create will use this one as its base.
Let's build it:
- Navigate to your GTM container and select Tags from the left-hand menu.
- Click the New button to create a new tag.
- Give your tag a clear name, like "GA4 - Configuration Tag". Consistency in naming will save you confusion later.
- Click inside the Tag Configuration box to choose a tag type. Select Google Analytics: GA4 Configuration from the list.
- In the Measurement ID field, paste the "G-" ID you copied from your GA4 property's Data Stream details.
- Leave the "Send a page view event..." box checked. By default, GA4 automatically tracks page views when the configuration tag loads, so keeping this enabled is standard practice.
- Finally, you need to tell GTM when this tag should fire. Below the Tag Configuration, click inside the Triggering box.
- Select the All Pages trigger. This ensures your GA4 base tag loads on every single page of your site, which is exactly what we want.
- Click Save.
That's it! You've just created the fundamental connection between your website and your GA4 property through GTM.
Step 2: Track an action with a GA4 Event Tag
Just tracking page views tells only part of the story. You also want to know what people are doing on your pages. Are they clicking buttons, completing forms, or engaging with key content? This is where GA4 Event Tags come in.
Let's walk through a common example: tracking clicks on a "Request a Demo" button. To do this, we need to create two new pieces in GTM: a Trigger and then the Event Tag itself.
Part 2a: Enable Built-In Click Variables
Before we build the trigger, we need to make sure GTM is listening for all the different details about a click. These are called Variables.
- Go to Variables in the left-hand menu.
- Underneath "Built-In Variables," click Configure.
- A list will slide out. Scroll down to the "Clicks" section and check the boxes next to Click Text, Click URL, and Click Classes. Ticking these boxes allows GTM to recognize these specific attributes of any click taking place on your site.
Part 2b: Create the Trigger
The Trigger's job is to listen for a very specific event—in this case, someone clicking our demo button. We’ll create a "trigger condition" so it only fires when the right button is clicked, not on any other link or button on the page.
- Head to Triggers in the left-hand menu and click New.
- Name your trigger something descriptive, like "Click - Request a Demo Button".
- Click the Trigger Configuration box and choose All Elements under the "Click" section. (While 'Just Links' also works, 'All Elements' is more versatile for tracking things that may not be a standard hyperlink, like
<div>s or<span>s styled to act like buttons). - Under "This trigger fires on," select Some Clicks.
- Now you’ll set the condition to identify your specific button. In the three drop-down boxes, configure a rule. For many buttons, the most reliable identifier is the text on the button itself. So, you would set a rule like:
- Quick tip: If different buttons have similar text strings, feel free to use 'equals' instead of 'contains' for greater precision. You could also target based on the link's destination (Click URL) or from its unique CSS identifier if one is available from the site’s backend (Click Classes).* Save your trigger.
Part 2c: Create the GA4 Event Tag
In the last part, we now make a proper event tag for ‘Demo Requests’, it now passes their data securely under GA's Event tracking using settings for tracking configuration you set earlier.
- Go to Tags and click New.
- Provide a name like "GA4 - Demo Request Click".
- Click inside the Tag Configuration box and select Google Analytics: GA4 Event from the list.
- In the Measurement ID field, select the GA4 Configuration tag you previously created.
- For the Event Name field, enter something like request_demo. GA4 prefers event names in lowercase with underscores for uniformity.
- Select the Triggering box and choose the trigger you created in the previous step.
- Click Save.
Your setup is fully ready, and the button tracking is now configured perfectly within GTM.
How to Test Your Settings and Publish!
This last stage is extremely common, yet very vital, check that your created tasks are working as expected. Google's testing platform enables users to confirm all setups perfectly right without affecting any live visitor experience.
- In GTM, in the upper right corner, choose Preview.
- Enter the web address you want to preview and press Enter. Your entered site will appear in a new browser tab alongside a separate debug session tab to review Tag Assistant activity directly.
- On the site itself, explore just as visitors would. Try out the tracked 'Request a Demo' button.
- In the debug pane, labeled "Summary," look in the Tags Fired panel. It should display which tags have fired as you interact with the site. Each action you perform should appear here, confirming that your tags are correctly configured and firing.
- Once everything is verified, click Submit on GTM and enter a descriptive name for your changes, like "Installed GA4 tracking setup".
Upon publishing your configuration, your site will be actively sending data to GA4, and you can start reviewing your analytics data soon.
Final Thoughts
Setting these tracking tags through GTM might initially seem complex, but with a structured approach, it becomes manageable. With your GA4 configuration and event tags in place, your site is now equipped to handle advanced tracking needs, providing valuable insights into user interactions.
As all new visitor activity data flows into Google Analytics, you’re equipped to make informed, data-driven decisions. If tracking complexities arise, there are solutions like Graphed, which uses natural language queries to create complex, real-time dashboards without extensive setup. It helps marketers pull insights from various data sources efficiently, ensuring all necessary data is readily accessible.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?