How to set up GA4 via GTM Server Side Tagging

Table of contents for how to set up GA4 via GTM server side tagging?  

  1. Configuration of client-side GTM container
  2. Configuration of server-side GTM container
  3. Preview and debug
  4. Validation in real-time
  5. Set up GA4 events in a server-side container using Universal Analytics events request
  6. FAQ

In this article, I will talk about how to set up GA4 via GTM server side tagging.

Note: This article is related to the server-side tagging articles below. If you haven’t read the earlier ones, I would highly recommend going through them. You can find them here:

  1. How to create server-side container for Google Tag Manager
  2. How to configure DNS for GTM server-side container
  3. How to send data from a website to a server-side Container

We have already created our server-side GTM container and configured DNS, so now we will proceed with configuring the client-side GTM container to set up GA4.

Configuration of client-side GTM container

Note: You can send data to a server-side container in the following ways:

  1. Using GTM: You can use regular GTM on the client-side to send data
  2. Using gtag.js: You can also use gtag.js to send data to a server-side container
  3. Custom code: You can also write custom code as well

In our case, I am using the regular version of the client-side GTM container.

Now follow the below steps to start configuring the client-side GTM container.

Step-1: Log in to your client-side GTM container and click on the ‘Tags’ tab.

Tags Tab 1

Step-2: Now, select your GA4 configuration tag. This is the tag that sends data directly to the Google Analytics server. We will be configuring it to send data to our server-side container and not directly to the Google Analytics server.

select ga4 tag

Step-3: A new overlay will appear. Click on the pencil icon to edit the tag settings.

pencil icon

Step-4: Now click on ‘Fields to set’.

Fields to set

Step-5: Now Click on ‘Add Row’.

Add row

Step-6: Now, in the ‘Field name’, add the value ‘transport_url’.

field name

Step-7: In the ‘Value’ section, you need to provide the tagging server URL so that instead of directly sending the data to Google Analytics, it will send data to our server-side container. 

You can find the tagging server URL in the ‘Admin’ section of the server-side GTM container. Copy this URL.

tagging server URL 2

Step-8: Paste the tagging server URL in the ‘Value’ input box and click on ‘Save’.

paste tagging server URL

Step-9: Now publish the container.

Congratulations! You have successfully configured your client-side container to send GA4 data to the server-side container. Now let’s configure the server-side container to send data to Google Analytics 4. 

Configuration of server-side GTM container

Follow the below steps to begin with:

Step-1: Navigate to your server-side container and click on ‘Tags’ and click on ‘New’.

Tags Tab 2

Step-2: Give your tag a descriptive name and click on ‘Tag configuration’.

GA4 server tag

Step-3: An overlay will appear on the right-hand side with a list of tag templates. 

Since server-side tagging is currently still in beta version, there are only three types of tag templates. ‘Google Analytics: GA4’, ‘Google Analytics: Universal Analytics’ and ‘HTTP request’. 

In our case, we will select ‘Google Analytics: GA4’.

GA4 Google Analytics

Step-4: Now, add your GA measurement ID. You can find it under Admin>>Data Stream of the Google Analytics 4 account.

add measurement id

Step-5: Click on ‘Triggering’ to create a trigger for our tag.

trigger 1

Step-6: Click on the ‘+’ icon to create a new trigger. Give a descriptive name to your trigger. Note that, like a typical GTM container, you don’t get the predefined trigger of ‘All Pages’ here. There is only one trigger type available at the moment, which is ‘Custom Trigger’.

Trigger Type 2

Step-7: Click on ‘Trigger Type’, and you can specify the trigger condition by selecting the ‘Some Events’ option. You can also create a new variable to define your trigger condition or choose the built-in variables.

custom trigger configuration 1

Step-8: In our case, we want to pass data to Google Analytics 4; hence we will select the condition as ‘Client name’ equals ‘GA4’.

equals ga4

Step-9: Click on ‘Save’.

As a next step, we will preview and validate if the server-side container receives data from the client-side container and how it sends it to Google Analytics.

Preview and debug

Follow the below steps to preview and debug.

Step-1: Now navigate to the server-side GTM container and click on ‘Preview’.

preview server container

Step-2: A new window will open like below with a blank summary.

blank window 1

Step-3: Go to your website and visit any page with the client-side GTM container code available on it. Switch back to the preview window, and you can see the pageview hit received from the client-side container, and, for the same hit, the Google Analytics 4 tag has fired.

GA4 Page View Tag Fired

As you can see from the below image, a page view request is generated, and a scroll event is also generated. This is because GA4 automatically tracks multiple events by default through enhanced measurement.

scroll evvent

To see the details of the tag fired, you can click on the ‘Tags’ tab of the preview window and select ‘GA4 Tag server-side’ (the name we given to the tag).

Tag fired details

The ‘Variables’ tab in the preview window will provide the list of variables enabled and their corresponding values.

Variables details

The ‘Event Data’ tab will provide you with all the information collected and passed to the endpoint tool, like Google Analytics 4.

Event details

Validation in real-time

Now navigate to your Google Analytics 4 account and click on ‘Real-time’. You should see the page view request below.

Realtime

So this is how you can set up GA4 using a server-side container. 

Set up GA4 events in a server-side container using Universal Analytics event requests

Let’s suppose you already have events set up for Google Universal Analytics in the web container (client-side) and wanted to send the same events in GA4 using the server-side container. This is very helpful where you can capture all your events data by just one type of client-side tag and do not need to set it up separately for GA4.

You can use Universal Analytics requests from the client-side GTM container and accordingly send data to GA4 with the help of the server-side container. 

There are few requirements for this set up: 

  1. All events you want to send in GA4 are already set up in the client-side GTM container using the Universal Analytics tag.
  2. Your client-side container sends data to the server-side container and not directly to the Google Universal Analytics server.

Follow the below steps to set up the GA4 events using Universal Analytics events in the server-side container.

Note: The below configuration will send all events from Universal Analytics set up in the client-side container to GA4 using the server-side container.

Step-1: Go to your server-side container, click on ‘Preview’ and check if the server-side container captures the Universal Analytics events data.

As you can see from the below image, my server-side container captures all the events from Universal Analytics Tag, and all information is available in the ‘Events Data’ tab.

events data

Step-2: Now navigate to the ‘Variables’ tab in the server-side container.

vairables in server side container

Step-3: Click on ‘Configure’ under ‘Built-in variables’.

Configure 2

Step-4: Now mark the check box ‘Event Name’.

checkbox event name

You will see that ‘Event Name’ appears as below in the built-in variables.

built in variable

Step-5: Now enable the preview mode of the server-side container and perform any event like scroll or click.

Note: Here, any events refer to any of the events that you have already configured in the client-side GTM container.

events in preview

Step-6: Now select any event and click on the ‘Variable’ tab in preview mode. You should be able to see the ‘Event Name’ parameter is populated with a value.

value in vriable name

If you can see the event name has populated with values, that means you have successfully configured the variable.

Step-7: Now click on ‘Tags’ in the server-side container and click on ‘New’.

Tags Tab 2

Step-8: Give your tag a descriptive name and click on ‘Tag Configuration’.

GA4 Events tag

Step-9: Now, select the tag type as ‘Google Analytics: GA4’.

GA4 Google Analytics 1

Step-10: Now add your GA4 measurement ID and click on the ‘+’ icon beside the event name.

measurement id

Step-11: Now select the ‘Event Name’ variable.

select event name

Your tag configuration will look like below.

Tag configuration 3

Step-12: Now click on ‘Triggering’ to create a trigger for our GA4 events tag.

trigger 2

Step-13: Click on the ‘+’ icon to create a new trigger. Give a descriptive name to your trigger. 

GA4 events trigger

Step-14: Now click on ‘Some Events’ and then select ‘Event Name’ from the drop-down under the condition.

some events

Step-15: Now select the condition from the second drop-down as ‘Matches regex’ and in the ‘Value’ input box type ‘.*

Note: The ‘.*‘ value will tell the server-side container to send all the Universal Analytics events to the GA4 server.

equals ga4 1

Step-15: Now save the configuration and enable server-side tag manager preview mode. 

Navigate to your website and perform any events. You can see from the below image that the scroll event and form submit event is fired in the summary tag, and at the same time, the GA4 events tag is also fired.

events in ga4 server side

Step-16: Now click on the GA4 events tag and see the details sent to GA4.

event fired

As you can see, the ‘GA4 Events’ tag has fired, and it also sent the ‘Event Name’ as ‘Form Submit’.

Step-17: Now navigate to Google Analytics 4 console and click on ‘Realtime’. You should be able to see the ‘Form Submit’ event as below.

real time form submit 1

Congratulations! You have successfully configured Google Analytics 4 events from Universal Analytics events using a server-side container.

Related Articles

Frequently asked questions about how to set up GA4 via GTM server-side tagging 

Can you set up GA4 using a server-side GTM container?

Yes, server-side tagging is a new way to use Google Tag Manager (aka GTM) in Google’s cloud environment. Just like Universal Analytics, you can also set up GA4 using a server-side container. You need to follow the below steps to set up GA4:
1. Set up a client-side container to send data to a server-side container
2. Configure server-side container to receive data
3. Create GA4 tag in a server-side container
4. Preview and debug
5. Publish the container

What is the difference between a client-side GTM container and server-side GTM container?

When we say client-side GTM container, we mean the GTM tracking code will run on the client machine (browser), and it will send data to the server-side GTM container. 

When we say server-side GTM container, that means it receives the analytics hits from the client-side container, processes the request. If it matches the condition of the server-side triggers then it sends data to the final analytics tool like Google Universal Analytics or GA4.

What is the difference between Google Universal Analytics and Google Analytics 4?

The biggest difference between Universal Analytics and GA4 is the measurement model. GA4 is based on an event-driven model and comes with a different set of reports, whereas Universal Analytics is more focused on a session-based data model. 

For more information, you can find it here. Google Analytics 4 (GA4) vs Universal Analytics – What is the difference?

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."



Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.



   

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade
error: Alert: Content is protected !!