icon

How to Add Google Analytics 4 to Google Tag Manager (Step-by-Step Guide with GA4 ID Setup)

Learn how to add Google Analytics 4 to your website using Google Tag Manager the right way. This step-by-step guide covers creating a GA4 property, getting the Measurement ID, and setting up tags with variables and triggers.

thumbnail image
8 min
Posted by :Sujal
Published on

You first need to make a Google Analytics account and property. So let's do that.

If you already have one, you can skip this Google Analytics Account creation section.

Google Analytics Account Creation

Step 1: Create a Google Analytics Account

  1. 2.
    Click the “Get Started Today” button.
  2. 3.
    Sign in with your Google account. If you don’t have one, create a new account.
  3. 4.
    On the welcome page, click “Start Measuring.”

Step 2: Set Up Your Account

google analytics account creation page
google analytics account creation page
  1. 1.
    Fill in the Account Name (e.g., your business or website name).
    ⚠️

    Note: The account name is different from your Google Analytics ID. You’ll create a property under this account to track your website.

  2. 2.
    Scroll down and click Next.


Step 3: Create a Property

google analytics property creation page
google analytics property creation page
  1. 1.
    Enter a Property Name (e.g., your website domain name).
  2. 2.
    Adjust the Time Zone and Currency to match your location.
  3. 3.
    Click Next.


Step 4: Describe Your Business

google analytics business details page
google analytics business details page
  1. 1.
    Select your Industry Category (e.g., Computers & Electronics).
  2. 2.
    Choose your Business Size (e.g., Small for 1–10 employees).
  3. 3.
    Click Next.


Step 5: Choose Your Business Objectives

google analytics business objective page
google analytics business objective page
  1. 1.
    Select “Other Business Objectives” to enable all features.
  2. 2.
    Click Create.
  3. 3.
    Accept the Terms of Service and click I Accept.


Step 6: Set Up a Data Stream

  1. 1.
    On the “Start Collecting Data” page, select Web.
    google analytics data collection page
    google analytics data collection page

  2. 2.
    Enter your website URL (without https:// or trailing slashes /).
    google analytics set up data stream page
    google analytics set up data stream page
  3. 3.
    Add a Stream Name (e.g., your website name).
  4. 4.
    Click Create and Continue.
  5. 5.
    Wait a moment—you’ll see the “Set up Google tag” page. Close it using the cross icon at the top.


Step 7: Copy Your Measurement ID

google analytics web stream derails page where you will find measurement Id
google analytics web stream derails page where you will find measurement Id
  1. 1.
    On the Web Stream Details page, locate your Measurement ID (starts with G-).
  2. 2.
    Copy this ID—you’ll need it for the Next.js setup.
  3. 3.
    Close the setup page. Click “Next” then click “Go to Home” to open your Google Analytics dashboard.


If You Already Have a Google Analytics Account

If you already have an account and just need to find your Measurement ID, follow these steps:

  1. 1.
    Go to the Admin page by clicking the gear icon in the bottom-left corner of your Google Analytics dashboard.
  2. 2.
    In the Admin section, click on “Data Streams.”
    select data streams
    select data streams
  3. 3.
    On the Data Streams page, find the website you’re tracking and click on it.
  4. 4.
    This will take you to the Web Stream Details page where you can copy your Measurement ID (it starts with G-).

Connect Google Tag Manager to Google Analytics

Now that you have your Google Analytics Measurement ID, let’s add it to Google Tag Manager.

Step 1: Open Google Tag Manager

  1. 2.
    You will see one or more accounts listed.
  2. 3.
    Select your organization, and then click on the container where you want to add Google Analytics.
    select your account
    select your account
  3. 4.
    It will take a couple of seconds to load the container dashboard.

Step 2: Create a New Tag

  1. 1.
    In the Overview tab, find the box labeled New Tag.
  2. 2.
    Click on “Add a new tag.”
    tag manager add a new tag
    tag manager add a new tag
  3. 3.
    A modal will open. Rename the tag by clicking the default title “Untitled Tag” — name it “Google Analytics Config” (as shown in the image).
    rename the tag
    rename the tag


Step 3: Configure the Tag

  1. 1.
    Click on the Tag Configuration box.
  2. 2.
    A modal will open with many tag type options.
  3. 3.
    From the Featured list, select the fourth item: Google Tag.
    select google tag
    select google tag


Step 4: Set the Measurement ID Using a Variable

Instead of pasting the Measurement ID directly, we’ll create a reusable variable.

  1. 1.
    In the Tag ID field, click the variable icon on the right.
    click variable icon
    click variable icon
  2. 2.
    A modal will open. Click the plus (+) icon in the top right corner.
    click the plus icon
    click the plus icon
  3. 3.
    Click on the default name “Untitled Variable” and rename it to “GA4 Measurement ID.”
    rename the variable
    rename the variable
  4. 4.
    Click on Variable Configuration to open the variable type modal.
  5. 5.
    Scroll down to the Utilities section and select Constant as the variable type.
    select constant
    select constant
  6. 6.
    In the Value field, paste your Google Analytics Measurement ID.
  7. 7.
    Click Save (top right corner, dark blue button).
    click save
    click save


Step 5: Add a Trigger

  1. 1.
    Scroll to the bottom to find the Triggering section.
  2. 2.
    If it’s not already selected, click the box and choose Initialization – All Pages from the three options.
    select all pages
    select all pages
  3. 3.
    This ensures your Google tag fires on all pages before any other tags — ideal for accurate pageview tracking and consent setup.


Step 6: Save and Publish

  1. 1.
    Click Save in the top right corner of the tag configuration page.
  2. 2.
    You’ll return to the dashboard.
  3. 3.
    At the top, click the Submit button to publish your changes to the live site.
    click submit
    click submit


Important Reminder

⚠️

If Google Analytics is already installed directly on your website, make sure to remove it at the same time you publish this new setup.

Having both the manual GA tag and the GTM-based GA tag will result in duplicate tracking, which can cause issues.

So: remove the original tag and only use Google Tag Manager going forward.

Need help with that? I’ve also linked a blog below on how to add Google Tag Manager to a Next.js 15 project.


✅ You’re Done!

You’ve now successfully added your Google Analytics tracking using Google Tag Manager!

If you’d like a visual walkthrough, here’s a great video that explains the same steps:



⚙️ See Handy Tools