This guide is designed to get you started as soon as possible with server-side tracking. You can think of it as a practical checklist to refer to each time you set up server-side tracking for your clients. If you are looking for a more detailed explanation, please refer to our introduction to server-side tracking article.
There are many types of containers in GTM. Up until now, you probably used only the web container.
🎬 Your Turn
It’s time to create a server container. Go to your GTM account > Admin > Create Container > Server.
The tagging server will be responsible for forwarding the data you collect to platforms like Facebook. Before, you sent this data directly using a tracking pixel.
🎬 Your Turn
Select the Automatic provisioning option. Make sure to add your billing account as well.
Note: This configuration is free until you increase the number of servers to handle more traffic.
You will see a window with your server’s information. The URL of your tagging server will look like this:
https://server-side-tagging-[XXXXXX]-uc.a.run.app
🎬 Your Turn
Test the tagging server by adding “/healthy” to your tagging server URL. You will see an “OK” if everything is working as expected.
https://server-side-tagging-[XXXXXX]-uc.a.run.app/healthy
The next step is to replace the default URL with our own custom domain. the data you will collect after this process is considered first-party. As long as you keep using the URL provided by Google, the tracking will be done in a third-party context.
🎬 Your Turn
Go to your Google cloud project by clicking on the icon next to your Project ID.
In the search bar, look for “cloud run”. You will land on a page containing your tagging and preview server.
Enable the two APIs.
You need to go to your hosting provider and add the A records.
Note: the SSL certificate will stay on pending until your domain is verified. This might take up to 24 hours or more.
Finally, browse to your server container > Administration > Container settings. Replace the old URL with the new custom domain (i.e., https://ssgtm.analygo.co/)
We can start using the server container at last. A client processes the requests from your web container and makes them available to your server-side tags.
🎬 Your Turn
Create a client by browsing to the client section in your server-side container.
In the client template, make sure to:
Tags receive the processed data from the client and fire according to the trigger. they work the same way web tags do.
🎬 Your Turn
Add a new GA4 tag and leave all fields with default values.
Add a new trigger and click on +.
Select Some events, and Choose Built-In Variable from the drop-down. add the Client name variable.
We need to add the URL of our server to the GA4 configuration tag.
note: we are now going to switch to the web container, so make sure you are not using server GTM
🎬 Your Turn
Open you GA4 configuration tag and select New variable under Configuration Settings Variable.
Now it’s time to test if everything is working as expected.
🎬 Your Turn
Open preview mode in both server and client containers. As you can see, the GA4 tag is working as expected.
The last thing we need to do is to make our set ready to hand handle more traffic.
🎬 Your Turn
Go to the integrations section in Cloud run and select server-side-tagging. You need to click on EDIT & DEPLOY NEW REVISION.
Scroll all the way down to Revision autoscaling. Change the minimum to 2 and up to 10 instances. Finally, you can click on Deploy.
Automated page speed optimizations for fast site performance