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 Universal Analytics. In fact, you won’t be able to move all tags from the web container to the server container since the GTM server container doesn’t yet have predefined clients and tags for the most popular platforms. And the template library is not available for the server container.  Even so, there is a way to move all your tags to the server container if you have a team of developers and analytics experts who can write tags and clients for you. 

In this article, I will describe the advantages of using GA4 and GTM server tagging. You can use it as a step-by-step guide on how to send events to GA4 via the GTM server container. As for eCommerce/enhanced eCommerce, I will cover it in another article.

What is Google Analytics 4, and why should you 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 the 4th version of Google Analytics? The answer is yes. It 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 was available for everyone since July 2019, but it had a different name — APP + WEB. Then, Google decided to rename it and make a big press release. That is how it got a new name — GA4.

If you want to register a new Google Analytics account, GA4 should be the default option. Google will ask you if you wish to create Universal Analytics property as well. But bear in mind that the GA4 interface is a far cry from the well-known Universal Analytics.

It looks like Google is telling users that it’s time to get used to GA4 and move their tracking from UA to GA4. After all, numerous changes were made to data collection and reporting.

How does GA4 differ from Universal Analytics?

1. Event-driven data model. 

The most significant change that was introduced is switching from the page view/sessions concept to the event-driven data model. This data model has been used for mobile apps analytics for several years now. The pageview model, however, does not fit mobile apps. It has to do with users having a completely different behavior when using apps and websites.  

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

 

2. Cross-device reporting

When it comes to traffic and sales analysis, cross-device user/conversion tracking is the main point. Let’s say a user saw your Adwords ad on the mobile and clicked on it. But for some reason decided to proceed with the checkout on the desktop. The user, however, did not log into any of the Google services. So, Google cannot recognize him and give credit to that particular Adwords click. As a result, the conversion source is lost, and the information for Adwords optimization is incomplete.

To solve this problem, Google released Signals a few years ago. Google integrated Signals functionality into GA4 and added machine learning. It is designed to identify users who are not logged into any of the Google services. If a user is not logged into the Google services or his device cannot be identified via fingerprinting, machine learning fills 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 managed to identify the most commonly used events that marketers and business owners track inside Google Analytics and GTM and added them 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 typically enabled for all GA4 properties. But you need 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 the analytics/reporting hub inside GA4. It allows users to create pivots, tables, and filters easily. There is also a template gallery, similar to what they have in DataStudio. So you will be able to analyze data more efficiently and spend less time on creating custom reports.

The next perk was a big surprise for me. Before, it was impossible to export raw data from the free version of GA to BigQuery. And today, BigQuery export is available to all GA4 users. In a nutshell, you can export GA4 data to BigQuery, which can be integrated with other sources like your CRM. Integration and sampling are the most popular reasons for upgrading to GA360 from my experience.

 

5. Other advantages

You might be already tired of reading about why GA4 is so cool. So I will list other 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, and lots more.

What is Google Tag Manager server-side tagging?

Let me quickly remind you what GTM server-side tagging is. And in the next section, we will start with the most exciting part – tracking setup. 

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 more. For example, you can use GTM server tagging to send information about events on your website to Slack; we have a quick guide here

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

Here we 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 table click + -> Add container name and choose Server under target platform -> on the pop up 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 in our service -> create container -> paste container config that you’ve copied on the previous step. If the setup was successful, you’ll see the status of the container 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, copy tagging server URL that -> 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 what tagging server URL you are using. These are the options:

1) Use a tagging server URL located under our domain (the one that you’ve copied in step 4). In this case, you don’t need to change anything.

2) Add a custom tagging URL. I recommend setting up a custom tagging URL that is located within the subdomain of your site. 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 ITPs

You need to create a DNS record inside your name service provider for a subdomain that you want to use for server-side tagging. Update it inside our service, google tag manager server container and Google analytics 4 tagging URL settings. For more detailed instructions, please check this post.

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:// 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. Open Google Tag Manager Server container -> click Client -> create GA4 client -> go to Tags and set up GA4 tag. Remember that GA4 automatically sends not only pageview but some other events. Inside Event Name choose variable {{Event Name}}. -> add trigger Client Name equals GA4.

ga4 server side trigger

7. Open the Server container preview 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?

This 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 setup inside the Google Tag Manager server container, please make sure that all Universal Analytics events inside the web container are working correctly. I will use Universal Analytics events from the web container to send data to GA4 inside the 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 them as events. 

If your GTM server container is not set up, please check this article for setup instructions.  

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. Start with setting up a new GA4 Client. Open GTM server container -> go to Clients on the left side menu -> click New -> Select GA4 -> Name your client and Click Save.

2. Set up the GA4 base tag inside Google Tag Manager Server Container. Go 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 this G-1XL11HCRG1) -> Set up trigger event name equals page_view. 

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

3. Create a new variable that will capture the event category from the requests that your Universal Analytics (that is set up inside the GTM web container) sends to the 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

4. Open the debug mode and verify that the event category variable (that we recently created) captures the event category correctly. You can either set up a test GA event inside the 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 clicks. 

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 the 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 the 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

5. Create triggers using the event categories that your Universal Analytics sends to the GTM server container. I recommend recording all event categories that you want to track inside GA4 into a text file. It will make the process of setting up triggers inside the 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

6. Set up triggers inside the GTM server container for all the event categories that you’ve written down in 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

7. 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 one of the 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

8. When you’re 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 events as conversions inside GA4, go to event -> all events -> turn the switch on for these events. 

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

How to send data from GTM web container to server container using GA4

Conclusion

GA4 and GTM server containers are still in beta, but you need to start utilizing these tools for your website analytics. GA4 and GTM server tagging were created to fit 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 for you or realize that you need assistance, feel free to contact us. We can answer your questions or do the setup for you. 

Want us to implement server-side tracking on your site?
Find out how much it'll cost!