How to Set Up GA4 Tracking Using Google Tag Manager Server-Side Container.

Google Analytics 4 and Google Tag Manager Server-Side container are the biggest updates in the analytics world in 2020 (or not only in 2020). These tools are still in beta; Google rolls out updates to both of them every week, but it shouldn’t stop you from testing it on your website. However, I do not recommend switching to only GA4 and GTM server tagging and disabling web container with Univeral Analytics. In fact, you won’t be able to move all tags from the web container to server container since GTM server container doesn’t yet have predefined clients and tags for most popular platforms, template library is not available for server container (in fact you can move all your tags to server container if you have a team of developers and analytics expert who can write tags and client for you). 

In this article, I will describe the advantages of using GA4 and GTM server tagging and give you a step by step guide on how to send events to GA4 via the GTM server container. In this blog post, I will not cover eCommerce/enhanced eCommerce. I will create another article for that.

What is Google Analytics 4 and why you should consider adding GA4 to your website?

The first question you might ask is why Google Analytics 4, were there versions from 1 to 3 and is it really the 4th version of Google Analytics? The answer is yes, this is the 4th version of Google Analytics. Everything started with Urching in 2005 then transitioned to Google Analytics (ga.js) in 2009 and Universal Analytics (analytics.js) in 2013. And now we have GA4.

google analytics history gtm server

GA4 has been available for everyone since July 2019, but it has a different name – APP + WEB. Google decided to rename it GA4 and make a big press release. 

If you want to register a new Google Analytics account, GA4 will be the default option. Google will ask you if you want to create Universal Analytics property as well. It looks like Google is telling users that it’s the time to get used to GA4 and move you tracking from UA to GA4.

GA4 interface is very different from our so well known Universal Analytics. They also made a lot of fundamental changes in data collection and reporting.

How GA4 differs from Universal Analytics?

1.Event-driven data model. 

The most significant change that was made is switching from page view/sessions concept to the event-driven data model. The event data model has been used for mobile apps analytics for several years. Pageview model doesn’t fit mobile apps since users have completely different behaviour when they are using apps compared to websites.  

The event-driven data model allows you to create an event for any activity on the website that you would like to record inside GA4. Plus you can use parameters that add more value and description to each event. Google prepared the list of standard event names that can be used inside GA4, but you can also create custom events and custom parameters.

2. Cross-device reporting

Cross-device users/conversion tracking has been the main point when it comes to traffic and sales analysis. Let’s say a user saw your Adwords ad on the mobile. Clicked on it, but for some reason decided to proceed with the checkout on desktop. On the desktop device, he is not logged in into any of google services, so Google is not able to recognise him and give credit to that particular Adwords click. Conversion source is lost, information for Adwords optimisation is not full. 

To solve this problem Google released Signals a few years ago. It was created to help identifying users who are not logged-in in any of Google’s services. Google integrated Signals functionality into GA4 and added machine learning. If a user is not logged into the Google services or Google can’t identify you via fingerprinting, machine learning will fill all the gaps. 

By the way, Google signals data collection is not enabled by default inside GA4. You need to enable it manually by going into settings -> clicking data setting -> data collection.

3. Predefined events

Google identified most commonly used events that marketer and business owners track inside Google Analytics and GTM and added it to the enhanced measurement functionality. Now page view, scrolls, outbound link click, site searches, video engagement and file download are tracked by default. This feature is enabled for all GA4 properties, but you might want to make sure that it’s turned on for your account. To do that, go to Data Streams -> choose Webstream details and check if all events are enabled.

enhanced measurement google analytics 4

4. Analysis Hub and integration with BigQuery. 

Google completely redesigned analytics/reporting hub inside GA4. It allows users to create pivots, tables, filters etc. easily. There is also a template gallery, similar to what they have in DataStudio. So you will be able to analyse data more efficiently and spend less time on creating custom reports. 

The next benefit is a big surprise for me. BigQuery export is now available to all GA4 users. Before it was impossible to export raw data from the free version of GA to BigQuery. BigQuery integration and sampling are the most popular reason for upgrading to GA360 (from my experience). And now you can export GA4 data to BigQuery and combine it with other data sources like your CRM.

5. Many other benefits…

You might be already tired of reading about the reason why GA4 is so cool, so I will just count other main benefits: built-in debug view, audience evaluation based on their probability of buying in the next several days, a combination of web and app analytics, etc.

What is Google Tag Manager server-side tagging?

Let me quickly remind you what GTM server-side tagging and in the next section with will start with the most exciting part – tracking set up. 

GTM sever container moves tracking from the user’s browser to the server. It has many benefits: improved page speed, better data security, ability to bypass 3rd party cookie blocking, AdBlockers and ITPs (if you use a custom subdomain, you can read about it here), increasing cookie lifetime and many others. For example, you can use GTM server tagging to send information about events on your website to Slack; I have a quick guide here

This article will give you more details about what GTM server-side tagging is. 

Here I will guide you on how to set up a GTM server container using our service.

How to set up Google Analytics 4 server side?

  1. Create Google Tag Manager server container. Inside Google Tag Manager click Admin -> Under container section click + -> Add container name. In the target platform section select Server -> on the popup choose manually provision tagging server URL (if you will use our service to set up tagging server) -> copy container config.
how to set up server tag manager create container name
how to set up server tag manager create container Manually provision tagging server

2. Create an account within our service -> create container -> paste container config that you’ve copied on the previous step. If the set up were successful, the status of the container would be Running. It will take up to 10 minutes to set up your container. Please refresh the page in 10 minutes to check the status of the container.

how to set up server tag manager create container set up gtm-server
gtm server container set up

3. After your container is set up and running, copy tagging server URL -> go back to the Google Tag Manager Server container -> choose your server container -> admin -> container settings -> paste tagging server URL.

how to set up custom domain google tag manager server container update tagging url

4. The next step depends on the tagging server URL you are using. You have to options here:
1) Use a tagging server URL located under our domain (the one you’ve copied on step 4). In this case, you don’t need to change anything
2) Add a custom tagging URL. I recommend that you set up a custom tagging URL located within your site’s subdomain. This blog post will show you how to add a custom subdomain. With a custom subdomain, you will get two huge benefits:

  • Cookie lifetime extension
  • Ability to bypass ad blockers and ITP

Custom tagging URL is available for Pro and Business subscriptions. To set up a custom tagging URL, please upgrade your plan and add URL inside our service. Once you’ve done that, you need to modify the Google Tag Manager code added to your website’s source code. Use tagging URL that is located on your subdomain and past it instead of www.googletagmanager.com. Make sure you didn’t delete /gtm.js.

add custom subdomain gtm server
how to set up server tag manager update tagging url inside the gtm code on your website

5. Inside the Web container click edit or create GA4 tag -> click Fields to Set -> add Row -> add these values: 

field name: transport_url

value: https://<DOMAIN_NAME> where DOMAIN_NAME is your tagging server domain name.

Save the tag (this tag should trigger on all pages) and publish the container. 

tagging url GA4 server-side tagging

6. Go to Google Tag Manager Server container -> click Client -> create GA4 client -> go to Tags and set up GA4 tag. Since GA4 automatically sends not only the pageview event, inside Event Name choose variable {{Event Name}} -> add trigger Client Name equals GA4.

ga4 server side trigger

7. Click preview inside the Server container, go to your site mode and check that you see GA4 requests. Publish updated inside server and web Google Tag Manager containers. 

ga4 server side preview
ga4 server side debug

How to set up GA4 inside Google Tag Manager Server Container using Universal Analytics requests?

The next method will show how to set up GA4 only inside the server container, without using Google Tag Manager Web Container. GA4 will work on the Universal Analytics requests. 

Before you start with GA4 set up inside Google Tag Manager server container, please make sure that all Universal Analytics events inside web container are working correctly. I will use Universal Analytics events form the web container to send data to GA4 inside server container

If some conversions inside your Universal Analytics are set up based on destination URL and you want to track the same goals inside GA4, please move them to the GTM and track it as events. 

If your GTM server container is not set up, please follow the steps from this article to set it up. 

Before you proceed with GA4 events set up, please make sure your tracking meets the following criteria:
1. All events you want to track inside GA4 are set up correctly inside Universal Analytics in the GTM web container. We will use Universal Analytics events to send data to GA4.
2. GTM server container is set up. (if not, follow this instruction)
3. Universal Analytics sends data to the server (if not follow this instruction)

1. Set up the GA4 base tag inside Google Tag Manager Server Container. Got to the tags tab on the left menu -> click New -> choose GA4 -> add your Measurement ID (you can find it inside your GA4 Property, it should look like G-1XL11HCRG1) -> Choose event Pageview -> add trigger “pageview” event.

How to Set Up GA4 inside Server-Side Google Tag Manager set up GA4 tag

How to Set Up GA4 inside Server-Side Google Tag Manager set up GA4 tag set up ga4 tag base trigger

2. Create a new variable that will capture event category from the requests that your Universal Analytics (that is set up inside GTM web container) sends to GTM server container. To do that open variable tab inside server container -> new variable -> query parameter -> Parameter Name type ec.

How to Set Up GA4 inside Server-Side Google Tag Manager set up variable

3. Open the debug more and verify that event category variable that we recently created captures event category correctly. You can either set up a test GA event inside web container or test it on your existing events. 

I’ve set up a test event inside web GA that sends an event with test parameters and triggers on all click. 

Category – test_category

Action – test_action

Label – test_label

How to Set Up GA4 inside Server-Side Google Tag Manager test tag

I see these results inside the GTM server container debug mode. 

If you don’t see the events inside the server container, please make sure that you published updates from the web container. 

You might notice that GTM server debugger takes too long to show the updates, from my experience it runs faster if you enable both web and server debuggers. But remember that it may affect the tracking since web debugger will push all not published changes to the server container.

How to Set Up GA4 inside Server-Side Google Tag Manager test events in debug

4. Create triggers using the event categories that your Universal Analytics sends to GTM server container. I recommend that you record all event categories that you want to track inside GA4 into a text file. It will make the process of setting up triggers inside GTM server container easier. To do that open your web container and copy all event categories from your web Universal analytics.

How to Set Up GA4 inside Server-Side Google Tag Manager create triggers

5. Set up triggers inside GTM server container for all the event categories that you’ve written down on the previous step. Go to triggers tab -> click new -> choose some events -> event category equals out here event category from your web GA.

How to Set Up GA4 inside Server-Side Google Tag Manager set up trigger

6. Set up tags that will send events to the GA4 via the server container. Open tags tab -> click New -> choose tag type Google Analytics: GA4 -> create tag name -> put your GA4 ID -> Add event name. You can choose from standard event names or create custom event names. You may want to add parameters to your events. There are standard event parameters, or you can use custom event parameters as well. I would recommend using standard event names and parameters. Repeat the same steps for all events that you want to track inside GA4.

How to Set Up GA4 inside Server-Side Google Tag Manager create tags

7. When you’ve done setting up all events, open the debug mode and test GA4 events. You may also want to open the Realtime section in GA4 and check that events are sent to GA4. You can click on the event name in GA4 and see event parameters

How to Set Up GA4 inside Server-Side Google Tag Manager preview results

8. In the end, don’t forget to publish your GTM server container changes. If you want to track newly created event as conversions inside GA4, open GA4 -> go to events section -> click all event -> turn the switch on for these events.

How to Set Up GA4 inside Server-Side Google Tag Manager track events as conversions

Conclusion

GA4 and GTM server container are still in beta, but you definitely need to start utilising these tool for your website analytics. GA4 and GTM server tagging were created to feet current world tracking rules, web technologies, restrictions and data security. You’ll need time to get used to the new interface and features and understand how it can better fit your website and  business needs. 

If you find migrating to the GA4 and GTM server container difficult or need some consultancy, feel free to contact us, we can answer your questions or simply do the set up for you. 

 

You can also test GTM severe tagging for free using our service.