fbpx
How to Setup and Install Google Analytics 4 with Google Tag Manager

How to Setup and Install Google Analytics 4 with Google Tag Manager

Google Analytics 4 (GA4) is the latest version of Google’s web analytics platform, and it offers a range of powerful features for tracking and understanding website visitors. Integrating GA4 with Google Tag Manager (GTM) can help simplify the process of tracking events and conversions on your website, as well as make it easier to manage and deploy tags.

How to set up the main GA4 code

The installation of the GA4 tracking code on your website starts with the gtag.js tag, which is the basic code required to track visitor data. By deploying this tag on all pages, you’ll be able to collect the default data recorded by GA4.

Google Tag Manager makes the implementation of this tag a breeze, with just a few clicks and the insertion of your GA4 account ID.

Note:- if you already have Universal Analytics (analytics.js) running on your site, you should keep it in place. GA4 and Universal Analytics can coexist, and maintaining your Universal Analytics properties will preserve your historical data. GA4 will only start recording data from the moment of its setup, not from the inception of your website.

Here’s the process of  install Google Analytics 4(GA4) with Google Tag Manager(GTM):

 

  1. Create a new GA4 property
  2. Create a data stream (in this blog post, I focused on the Web stream)
  3. Copy the Measurement ID
  4. Create a Google Analytics 4
  5. Configuration tag
  6. Paste the Measurement ID and set
  7. the tag to fire on All Pages
  8. Preview/test the new tag
  9. Publish the changes in Google Tag Manager

As you can see, everything is pretty straightforward. So let’s dive in.

In this blog post, we will provide a step-by-step guide on how to set up GA4 with Google Tag Manager.

Step 1: Create a GA4 Property

To start, you need to create a GA4 property in Google Analytics. If you already have a Google Analytics account, you can create a new GA4 property by clicking on the “Create Property” button in the GA4 section of your account. If you don’t have a Google Analytics account, you’ll need to sign up for one and You’ll need to provide basic information about your website, such as the website name and URL.

create google analytics 4 property

After entering your property name, which could be your website name, company name, brand name, etc., it’s time to specify your company’s country, reporting timezone, and main currency of operation. Simply press Next, answer a few questions, and then click Create to have your new property ready.

GA4 Property Setup

The final step in the setup process is to configure your first data stream. This data source will allow events to be transmitted to your GA4 property. You may have multiple data sources within a single property, such as three web properties, one for an Android app, and one for an iOS app.

In this blog post, I will focus on a Web stream. Select it.

data stream

After entering URL of your website(for example, https://www.bettershopme.com), ensure that the protocol (https) is already selected. Follow that by providing the name of your website.

When creating a web data stream in GA4, you have the option to enable or disable Enhanced Measurement. This feature is designed to assist marketers in obtaining a comprehensive view of events in their reports, without requiring assistance from developers or manual configuration in GTM.

Setup data stream

By default, Enhanced Measurement is enabled in Google Analytics 4, which enables the automatic tracking of the following events:

  1. Page view (event name: page_view)
  2. Scroll (event name: scroll)
  3. Outbound link click (event name: click with the parameter outbound: true)
  4. Site search (event name: view_search_results)
  5. Video Engagement (events: video_start, video_progress, video_complete)
  6. File Download (event name: file_download)
  7. Form events (form_start, form_submit)

You have the flexibility to enable or disable each event by clicking the gear icon in the Enhanced Measurement section and then toggling the buttons. Press the Create stream button and you are ready.

Enhanced Measurement

Step 2: Get Your GA4 Tracking Code

Once you have created your GA4 property, you’ll need to get your GA4 tracking code. This code is unique to your GA4 property, and you’ll need to add it to your website in order to start tracking visitors.

To find your GA4 tracking code, go to the GA4 property you just created and Click the “Data Streams” option, and select “Web” menu. Click on the arrow (>) under “Data Stream” to go to “Web Stream Details” page. You’ll see a code snippet that you’ll need to add to your website.

GA4 code

Now on the “Web Stream Details” screen, under “Tag Instructions” tab find “Add New On-Page Tag”. This is where you can find “Global Site Tag (gtag.js).” Copy and paste this code into the <head> of every web page you want to measure.

GA4 code_1

Step 3: Create a GA4 Tag in GTM

Next, you’ll need to create a GA4 tag in Google Tag Manager. To do this, log in to your GTM account and click on the “Tags” section. Then, click on the “New” button to create a new tag.

tag manager1

CopIn the tag configuration screen, select “Google Analytics: GA4 Configuration” as the tag type. 

Gtm Tim Jensen 2 800x343

Then,In Google analytics>Admin in data steam you created data stream (web), you will see a Measurement ID like below screen shot.  

GA4 measurement id

Copy and paste the Measurement ID you obtained in the above step into the “GA4 Configuration” field.

Google Tag Manager >> Tag Configuration >> GA4 'Measurement ID'

Step 4: Configure the GA4 Tag to Fire on All Pages

After you have created the GA4 tag in GTM, you’ll need to configure it to fire on all pages of your website. To do this, you’ll need to set up a trigger that fires the tag on all pages.

Go to the “Triggering” section of the tag configuration screen, and click on the “New” button to create a new trigger. 

Google Tag Manager >> Tag Configuration >> GA4 'Measurement ID' >> Triggering

Select “All Pages” as the trigger type, and save the trigger.

Google Tag Manager >> Tag Configuration >> GA4 'Measurement ID' >> Triggering >> All Pages >> Choose a trigger

Rename this tag from “Untitled Tag” to “GA4 Configuration Tag” or the name of your choice. Click on Save for saving this tag.

GA4 Config

Step 5: Verify the GA4 Tag is Working

Now that you have created and configured the GA4 tag in GTM, you need to verify that it’s working correctly. To do this, you can use the Preview and Debug mode in GTM, or you can check the real-time report in GA4.

Google Tag Manager - Preview

In the Preview and Debug mode, you can see a live preview of your website and track the events that are being sent to GA4. In the real-time report in GA4, you can see the events that are being recorded in real-time.

Check the Tag is firing Correctly in GTM

Click on the “Preview” button.

Google Tag Manager - Preview

Enter the URL of the website and click the “Connect” option.

GTM Preview

Check if the “GA4 Config Tag” appears under “Tags Fired”. Then your tag is installed correctly. 

GTM Config tag fire

Now go back to Google Tag Manager Tab and click on “Submit”.

Google Tag Manager Tab - Submit

Give  “Version Name” and add a detailed description of the changes made in this version. Click on the “Publish” button.

Tag Manager - Version Name - Detailed Description - Publish

Conclusion

Establishing Google Analytics 4 can be a challenge, as is the case with all new endeavors. This guide aims to simplify the process and make it more manageable for you. If you have any further questions, don’t hesitate to reach out