how to install ga4 through gtm

How to Install Google Analytics 4 (GA4) Through Google Tag Manager (GTM)

Google Analytics 4 (GA4) is an essential tool for understanding your website traffic, user behaviour, and marketing performance. While there are several ways to install GA4 on your website, using Google Tag Manager (GTM) is widely considered the best practice.

GTM allows you to manage all your tracking codes in one place without having to edit your website’s source code every time you want to add a new tracking event.

In this step-by-step guide, we will walk you through exactly how to set up GA4 on your website using Google Tag Manager.

Prerequisites

Before we begin, ensure you have the following:

  1. A Google Account: To access both GA4 and GTM.
  2. An active Google Tag Manager account: Your GTM container code should already be installed on your website’s <head> and <body>.
  3. Admin access: You need sufficient permissions to make changes in both GA4 and GTM.

Step 1: Create a GA4 Property and Data Stream

If you haven’t created a GA4 property yet, you need to set one up to generate the unique tracking ID for your website.

  1. Go to analytics.google.com and log in.
  2. Click on the Admin gear icon in the bottom-left corner.
  3. Under the Account column, click Create Property.
  4. Enter your property details (Website Name, Time Zone, and Currency), then click Next.
  5. Answer the brief business details questions and click Create.
  6. Once the property is created, you will be prompted to set up a Data Stream. Select Web as your platform.
  7. Enter your website URL and a Stream Name (e.g., “My Website – Web Stream”).
  8. Ensure Enhanced Measurement is toggled ON (this automatically tracks page views, scrolls, outbound clicks, etc.).
  9. Click Create stream.

Step 2: Locate Your Measurement ID (Tag ID)

To link GA4 to GTM, you need your unique identifier, known as the Measurement ID.

  1. Once your Web Stream is created, a “Web stream details” panel will open.
  2. In the top-right corner of this panel, look for the Measurement ID.
  3. It will look something like this: G-XXXXXXXXXX.
  4. Click the copy icon next to it. You will need this for GTM.

(Note: If you already had a GA4 property, you can find this by going to Admin > Data Collection and Modification > Data Streams, and clicking on your web stream.)

Step 3: Configure the Google Tag in GTM

Recently, Google updated GTM by replacing the old “GA4 Configuration Tag” with a unified “Google Tag”. Here is how to set it up:

  1. Open a new tab and go to tagmanager.google.com.
  2. Select the container for your website.
  3. In the left-hand menu, click on Tags, then click the New button in the top right.
  4. Name your tag: In the top-left corner, rename “Untitled Tag” to something clear, like Google Tag - GA4.
  5. Click anywhere in the Tag Configuration box.
  6. From the menu that slides out, select Google Analytics, and then choose Google Tag.
  7. In the Tag ID field, paste the Measurement ID (G-XXXXXXXXXX) you copied in Step 2.
  8. Click anywhere in the Triggering box below.
  9. Select the Initialisation – All Pages trigger (or the standard All Pages trigger). This ensures GA4 fires on every page load across your website.
  10. Click the blue Save button in the top right.

Step 4: Preview and Test Your Setup

Before publishing your changes to the live website, it’s crucial to test if the tag is firing properly.

  1. In your GTM workspace, click the Preview button in the top right corner.
  2. A new “Tag Assistant” tab will open. Enter your website’s URL and click Connect.
  3. Your website will open in a new window with a “Debugger Connected” badge in the corner.
  4. Go back to the Tag Assistant tab. Under the “Tags Fired” section, you should see your new Google Tag - GA4 listed.
  5. Bonus Check: Go back to your GA4 tab. Navigate to Admin > Data Display > DebugView. As you click around your preview website, you should see events (like page_view) populating in real-time on the GA4 timeline.

Step 5: Publish Your GTM Container

If your tag fired successfully in Preview mode, it’s time to push it live!

  1. Close the Preview windows and return to your main Google Tag Manager workspace.
  2. Click the blue Submit button in the top right corner.
  3. Enter a Version Name (e.g., Added GA4 Base Tracking) and a brief description so you or your team have a record of what changed.
  4. Click Publish.

Last item Note

You have successfully installed Google Analytics 4 on your website using Google Tag Manager.

It may take 24 to 48 hours for data to fully populate in your standard GA4 reports. Moving forward, you can use this exact same GTM container to set up custom GA4 Event Tags, allowing you to track button clicks, form submissions, purchases, and much more without touching your site’s code.

This is default text for notification bar
This is default text for notification bar