How to setup GA4 server side tracking
The standard, default Google Tag Manager implementation of GA4 is client side tracking. It means that client, in this situation: users browser like Google Chrome or Mozzila, is responsible for launching GTM/GA4 scripts and sending them to Google.
In this article we will introduce another approach and we will implement server side tracking where tracking scripts are processed by server not client. This solution has some advantages:
- Reduced load on a page
- Reduce the impact of ad blockers
- Include user-provided data from your website
- Control what kind of data is sent to vendors
And also some disadvantages:
- it is a paid solution – you have to pay for the server. The cost depends on volume of your traffic and number of tags. The cost start from about 100$ monthly. Good that Google will offer you $300 credit for free to test the service until you will decide to pay for it.
- you need to additional effort to setup your account in Google Cloud Console. You will need also to make some adjustments in your domain settings in order to setup custom domain for your Ap p engine in Google Cloud Server if you want to use full potential of server side tracking.
Server side tracking is for you if you have large traffic volume on your website and you relay on data. If you have just started you ecommerce please use standard client side tracking and come back here when your business will be more developed.
Step by step guide how to implement server side tracking for GA4.
- Go to the Google Tag Manager starting page(list of your accounts) and click “Create Container”
- Then name it, chose “Server” and click “Create”
- In the next step you will have to setup you server side tracking server. Please go with “Automatically provision tagging server”.
- Then please set up you billing account using your credit card number in Google Cloud Platform. Google will give you $300 credit for free to test this service until you decide if want to pay for it.
- After you setup you billing account in the next step you will be able to create you server. Chose your billing account and click “Select billing account and create server”.
- You have just created server for server side tracking. In the next screen you will get you server details. You can check also this details in the future by clicking your GTM number in you server side tracking container. The most important here is to copy your default url which you will need in the next step.
(If you have access to your domain setting you can setup your custom domain which is recommended if you want to use full potential of server side tracking, here is instruction how setup custom domain for server side tracking, to go directly to your GTM server side project please use the link which is available just next to the Google Cloud Platform Project ID – on the screen). - Now you need to create GA4 client tag in you Google Tag Manger server side container. Go to your Google Tag Manager server side container and create new tag. You have there fill your GA4 Measurment ID (you will find this number in Google Analytics in your GA4 property). Create new trigger using flowing setup:
- Go to your standard client side container where you have all GA4 tags and update your GA4 configuration tag with your google cloud server url (or custom domain if you were able to setup it).
- Update the gtm.js source domain. When you install gtm.js on your website, the default configuration loads the Google Tag Manager libraries from www.googletagmanager.com. To load the GTM code via your server container, change this domain name to the domain of your server container for both the gtm.js script and ns.html file, and add new client type to your server side tracking container (Google tag manager: web container).
- Update your data layer with clients details variables. To do that you need to your website data layer code customer details variables and values.
- Create new data layer variables in Google Tag Manager. To do that go to variables in GTM, create new and name it like: “customer_email”, choose variable type as Data Layer Variable and fill data layer variable name like “customer_email” and save it. Repeat this process for all your customer details variables.
- Create new User-Provided Data variable using your variables from the previous point.
- Upgrade GA4 Configuration tag with user provided data. Go to your GTM GA4 Configuration tag settings and mark: “include user-provided data from your website (Server only)” and chose your user provided variable that you have created in previous step.
- One more thing you can do to unlock even more potential of server-side tagging is to load supported gtm scripts via your server container using custom domain instead of default one which is: googletagmanager.com. This reduces your reliance on a third-party domain and impact of adblockers.
To do that please follow instruction published here: https://developers.google.com/tag-platform/tag-manager/server-side/send-data#update_the_gtmjs_source_domain.
If you enjoyed the content please share it:
If you have any question about this topic feel free to comment or react below.
Some time ago I listened to a podcast from the Technical Marketing Handbook series from Simo Ahava, whose guest was Adam Halbardier from the Google Tag Manager product team. During the conversation, the topic of transparency of data handled by the Server-Side container appeared.


Facebook conversion tracking on the server side gives you oportunity to minimize usage of java script libraries on the client side and may reduce page load time. Running facebook conversion tracking codes on the server side may gives you better security for your clients data. You can have also more control over the data and decide which you want to send to facebook. Additional feature is that this solution minimizes the impact of ad blockers.


Implementation of Google Ads server side tracking has couple of advantages:
- it may help to improve your page load time by reducing the amount of code you have to run on client side
- it may reduce the impact of ad blockers
- you will have more control what kind of data you sending to external vendor


Environment - is a set of necessary elements of technical / software infrastructure, which is the basis for the operation of a given website/application. Google Tag Manager environments are simply multiple versions of the same container. When we have a website with a different version for development, testing, production and QA, instead of creating separate GTM containers for each version, we can set up separate environments in the same container that will work independently in each version.


Some time ago I listened to a podcast from the Technical Marketing Handbook series from Simo Ahava, whose guest was Adam Halbardier from the Google Tag Manager product team. During the conversation, the topic of transparency of data handled by the Server-Side container appeared.


If you plan email marketing campaigns you are interested in the same as with other campaigns, to measure their impact on your business. When you are starting with this topic it is good to know that without additional effort you will not be able to access this impact. You will see no results because Google Analytics will treat traffic from the email campaigns as direct traffic (when users are using your own app) or as referrals (when users are using web email clients).
