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

Author
Stape
Published
November 12, 2020
Also available in

Google Analytics 4 and Google Tag Manager Server-Side container are the biggest updates in the analytics world in 2020. 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 GTM clients.  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?Copy link to this section

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

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 would 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?Copy link to this section

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 and SPA. 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 recommended 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 settings -> data collection.

Another essential setting (and a new one) that you should consider checking is how GA4 identifies users.

They have two options: 

  • by device only (what we used to have in Universal Analytics standard property)
  • by user-id, Google Signals, then device (new option)
google analytics 4 reporting identity

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.

google analytics 4 standard events

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 UA 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. Limit of Custom dimension and Custom metric.

In GA4, the limit of custom dimensions and metrics increased. Google Analytics 4 allows to have 25 user scoped, and 50 events scoped custom dimensions. Custom metrics increased to 50. In UA, you can have only 20 custom metrics and 20 custom dimensions. Increased number of custom metrics and dimensions gives more flexibility for customization of GA4.

6. GA4 debug view.

GA4 debugger is extremely helpful for people setting up Google Analytics 4. With the enabled preview, you can see what events, event properties, and user data GA4 processes. It makes the process of configuring GA4 much faster and easier. Love this feature.

google analytics 4 debug view

7. Other advantages

You might be already tired of reading about why GA4 is so cool. So I will list other benefits: 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?Copy link to this section

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 server 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?Copy link to this section

1. Create a 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 use our service to set up tagging server) -> copy container config.

set up server google tag manager container 
container config server google tag manager 

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.

set up container stape
set up container stape

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

tagging server URL Stape
set tagging server url in gtm

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.

set custom subdomain stape
update google tag manager script stape

5. Inside the Web container click edit or create GA4 configuration tag -> enable Send to server container -> add Server Container URL: 

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

set up google analytics 4 server side 

6. Open Google Tag Manager Server container -> click Client -> create GA4 client and save it -> 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.

set up ga4 tag in the server container 
set up ga4 client in the server container 

7. Open the Server container preview mode and check that you see GA4 requests. Publish updated inside server and web Google Tag Manager containers. 

test ga4 trigger in the server container 

Custom GA4 loaderCopy link to this section

You can make Google Analytics 4 server-side tracking even more accurate by using a custom GA4 loader. This will allow GA4 to work around any blocking tools, such as ad blockers and other privacy-related technologies that aim to prevent trackers from gathering data about visitors' activities. As a result, you'll see the complete picture of users visiting your site and have more data for ad optimization and custom audiences.

To enable the GA4 custom loader, login to the stape.io account, select the sGTM container, head over to the power-ups section, and click config Custom Loader. You should add a Web container ID and select your sGTM domain. Once done, copy the web GTM code that you see in stape admin, add or replace the web GTM script on your site, and click save changes.

custom google analytics 4 loader 

Once you've updated GTM on your site, you can verify changes by opening the network tab and checking the GA4 request's path. It should be replaced with random symbols.

ga4 adblocker 

ConclusionCopy link to this section

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.

Host your GTM server at Stape

By signing up you agree to Stape’s Terms of Use and Privacy Notice