Step by step guide on how to set up Google Analytics 4 with Google Tag Manager

Written by Cristina Muñoz on 16th November 2022

(Last updated 28th February 2025)

As of 2023, Universal Analytics stopped existing and all accounts were moved to GA4.  

The deprecation of UA forced many website managers to rethink how they collected and analysed their data. Whatever your opinion on GA4 is, Google Analytics is still one of the market leaders in web analytics. It is heavily based on custom events, so you won’t get a nice set of pre-configured events to track, as was the case with UA. This is really useful if you want to customise your report to your own business goals, but it will require some knowledge. Using Google Tag manager can save you time because you only need to add code to your website once. From then on, all the custom events you create can be done from the GTM interface. In the past at Liquid Light, we have used the gtag.js setup with Universal Analytics. Making the change to using Google Tag Manager to implement analytics tracking has empowered our wider team to make such changes. 

 

Why set up GA4 with GTM?

  1. Saves developer time - you won’t have to ask a developer or someone with editing access to your website code every time you want to add a new code or make a small tweak.
  2. Integrations! - there are so many integrations with GTM. Aside from Google Analytics, there are many other third-party code snippets you can add through custom HTML tags. For example, if your client uses Hubspot, you can add the Hubspot tracking code through the HTML tag. Something that us non-developers can do, again helping with time responsiveness.

Setup and Install Google Tag Manager

We’re assuming that you aren’t already using Google Tag Manager but if you’re unsure then you can easily check whether GTM has been previously installed on your website by looking at the website’s source code. 

How to check your website source code? 

  1. View your chosen website in any web browser
  2. Right click and select one of the following options:
    1. Chrome and Firefox - View page source
    2. Microsoft Edge and Internet Explorer - View source
    3. On a Mac the option will be View page source
  3. Make a "Control+F" (or "Command+F" on a Mac) search for GTM. If there’s a GTM container installed on your website, then it will be highlighted in the code.

GTM is very easy to setup, like most of Google’s services the process is smooth. Head to GTM - Home and follow the setup instructions.

Install the GTM code on your website 

Once you have completed the steps to create a new container in GTM, it will give you a code to add into the header and main body of your website. This is where a developer or someone with access to the website code comes in. Send them the instructions and code given to you.

Step by step set up of Google Analytics 4

The next step is to setup your GA4 property. There’s two ways to do this. 

  1. Set up GA4 through your existing Universal Analytics account
  2. Create a brand new GA4 account. If you have a new website, you can set up a new GA4 account. Follow the below steps to connect them together.

Create new GA4 Property from UA and integrate with Tag Manager

  1. From main UA property, click Admin > GA4 Setup Assistant
  2. Click Get Started
  3. In the new GA4 property navigate to home dashboard and copy the
    Measurement ID: G-ABC123456
  4. Go to Tag Manager, and click on Variables in left side bar
  5. Create new variable 
    • Give it a name: GA4 Measurement ID
    • Variable Type: Constant
    • Value: G-ABC123456
  6. Create new Tag in Tabs menu (see Tag Configuration screenshot below)
    • Give it a name: GA4 Pageview
    • Select GA4 Configuration
    • Measurement ID: GA4 Measurement ID
    • Open Fields to Set: (this is optional)
      1. Field name: gtm_container and the value: {{Container ID}} (this can be found in Built-in variables)
      2. Field name: debug_mode and the value: {{Debug Mode}} (this can be found in Built-in variables)
    • Select Trigger All Pages
  7. Click Save
  8. Once you have set this up (and any other tags you wish to create), head to preview to test that your tags are firing.
  9. Lastly, after testing it’s all working correctly, don’t forget to publish the changes to the container.

 

Why create a new variable for the GA4 Measurement ID?

By creating a variable for your GA4 measurement ID you can maintain all your standard settings across tags, for example, Property Settings, Fields to Set, Custom Dimension and Custom Metrics. This saves you adding these settings to every tag you create in the GTM container. 

Why add gtm_container and debug_mode to Fields to Set?

gtm_container

This will help in the future in case you run multiple containers on the same project, we can narrow down things by container.

debug_mode

This allows debugging custom events in the Debug section in Analytics.

Once the GA4 tag has been configured, give your Google Analytics account up to 24 hours to start collecting data. 

Yes, it’s really that simple… There are many other custom GTM tags you can set up which may suit your goals. For example, we like to track how users interact with each area of a webpage, so we may set up tags such as footer clicks and social profile clicks. Over time, we can begin to understand how users interact with a website, and the purpose of their visit.

Frequently Asked Questions:

What does GA4 automatically track?

GA4 has offered enhanced measurements which in Universal Analytics you would have had to set up through adding custom codes. 

  • Page views
  • Scrolls
  • Outbound clicks
  • Site search
  • Video engagement
  • File downloads

Other interactions to consider tracking:

  • Button clicks
  • Main menu clicks
  • Footer clicks
  • Social Share clicks
  • Social Profile clicks
  • Toggle Box Clicks
  • Tab Clicks

How do I track Internal Traffic on GA4?

Within the GA4 settings, you can add your work IP address. This will remove the traffic from those IP addresses from your reports. This is particularly useful if companies use their website to work on. This way, you can collect data solely on external users. 

  1. Log on to your GA4 account.
  2. Click on Admin > Data Stream
  3. Under Additional Setting click More Tagging Settings > Define Internal Traffic
  4. Rule name, e.g. Office IP Address
  5. Unter IP Address click on Match Type and select IP address equals
  6. Enter the IP address (in this example the office IP address)
  7. Click ‘Create’. 

There is a second step in order to make this active:

  • Head to Admin > Data Filter
  • Click on the arrow to the left of Internal Traffic
  • Under Filter State, select Active 
  • Click ‘Save’.

Your data will now start excluding the internal traffic. 

We hope further down the line, that you will be able to see both external and internal traffic. If a company works on the website a lot, it’s important to understand how they use it, and from that whether improvements can be made.

 

How to check your events are firing in Google Tag Manager? 

Once you have made all your changes to your GTM, whether that’s adding new triggers and tags, you can then test them all before publishing. In the top right corner, there is a preview button. This will open GTM debugging mode. Enter your website URL and it will load a new screen. If you see your GA4 Page Tag being fired, this means you have successfully uploaded GA4 to GTM.