How to Set Up Google Tag Manager Server-Side Tagging

Would you like to transfer to server-side tracking?

A website running client-side tracking relies on a container in the page to send measurement data to various collection servers. This container runs on the user’s browser or phone and has a direct connection to the mother server of your tracking tools. 

Server-side tracking creates an interface between the two by enabling you to build your own tracking server. Google Tag Manager server-side tagging runs on the Google Cloud Platform and acts as a proxy between your client-side tracking and your marketing vendors. 

Sign up to the FREE GTM for Beginners Course...

From the browser, data gets sent to the GTM server-side instance and then forwarded to your tracking tools. This allows you to circumvent certain ad-blockers that hinder sending data to your tracking tools, and save data resources leading to an improved user experience.

In this guide, we’ll show you how to set up Google Tag Manager server-side tagging.

Here’s an overview of what we’ll cover:

Server-Side Instance Setup

Let’s create a GTM server-side instance.

Log in to Google Tag Manager and set up a new account by clicking on Create Account.

Creating a new account in Google Tag Manager

Typically, you are setting up server-side tracking for a company, so let’s use their name for the account name.

Type the account name in the space provided.

Adding an account name

You can also specify the country and optionally choose to share data anonymously.

Next, we need to provide the container name. I recommend putting your website domain in this field to help keep everything clean.

Fill in the container name, then click on Server for the target platform. Finally, click on Create.

Google Tag Manager server-side tagging container

We are then shown the terms of service agreement. Read through this article and ensure that you accept these terms.

Tick the check box below and click on Yes to accept. 

Accepting GTM’s terms of service agreement

Next, we’ll set up our tagging server. Here, we can automatically or manually provision the tagging server. If you already have your own server ready, you can follow the link for the user guide to manually set up the tagging server.

We’ll use the automatic provision option to deploy GTM server-side tagging through the Google Cloud Platform. Sign up and create a billing account here if you haven’t already.

Click on the Automatically provision tagging server button. 

Automatically provision tagging server set up

To create our tagging server, we’ll then select our billing account. If you already have a billing account in the Google Cloud Platform, it should be automatically selected. 

Click on the Select billing account and create server button.

Selecting the billing account for creating the tagging server

Creating a server may take a few minutes. Once created, we’ll see a window showing information such as the Google Cloud Platform project ID and the default URL. This is the server created where we can try out our GTM server-side instance. 

Note that this is only a free sandbox for us to test our tags. If you want to run this on a live website, you will need to upgrade to a production version, which will cost you more.

Let’s click on Close

Closing the server details window

Server-Side Preview Mode

If we look at our server-side instance, it looks like a typical Tag Manager workspace. The only difference is a new tab called Clients

New client tab in Google Tag Manager

Clients are a new kind of entity for use in server containers. The client receives measurement data from a user’s device, turns it into events, routes data to be processed in the container, and packages up the results to send back to the requester.

Let’s verify if our server is reachable.

Click on our container ID.

Opening container details

Copy the default URL.

Copying server default URL

Next, click on Preview

Preview mode for server containers

Instead of connecting GTM to our website, this puts our server-side instance into debug mode and opens a tab that looks similar to the Tag Assistant.

Server-side debug mode

Opening our server (using the default URL we copied earlier) on another tab, we get the HTTP error 400. 

HTTTP error 400 on tagging server

It seems like our server cannot be reached, but if we look inside our server-side preview mode, there is a new entry. 

Click on the new entry, then open the Request tab.

A new entry in the server-side preview mode

We can see that none of the clients claimed the request, and nothing has been returned. We do, however, have an incoming request, which is a slash. This is confirmation that our server is reachable.

Our GTM server-side instance is already set up. Therefore, we can go ahead and send data to our server-side instance, then relay this information to the Google Analytics 4 endpoint. 

Sending data to the Server-Side Instance

Let’s go to our client-side Tag Manager account that is connected to our website.

Create a new tag by clicking on TagsNew.

Creating a new tag in the client-side GTM account

We’ll be sending our data to Google Analytics 4, so we’ll need to make a Google Analytics configuration tag. 

If you’re still using Universal Analytics, check out our GA4 migration guide.

Select Tag ConfigurationGoogle Analytics: GA4 Configuration.

Creating a GA4 configuration tag

To configure our tag, we’ll need our website’s measurement ID on Google Analytics. 

In your Google Analytics account, go to the admin section by clicking on settings. Go to Data Streams and select your domain. 

Opening the website data stream on Google Analytics

Copy the measurement ID.

Website measurement ID on Google Analytics

Paste this value back to Tag Manager. Check the Send to server container option, then paste our server container URL in the space provided.

GA4 tag configuration for sending data to the server container

Let’s attach a trigger by clicking on Triggering.

Applying a trigger

Choose the All Pages trigger.

Applying the all pages trigger

Finally, ensure our server container URL does not end with a slash, apply a tag name, then click Save.

Completing the GA4 configuration tag

Now, let’s preview this tag by clicking on Preview

Preview mode on GTM

Then, click on Connect.

Connecting the Tag Assistant to the website

Now, the data that should be sent to Google Analytics 4 will be relayed to our new server container URL.

If we check our server-side instance preview mode, we should have a page_view entry.

Page view entry in the server-side preview mode

We can see details such as an incoming HTTP request and the client that claimed this request.

Default Client Event Data

Google Tag Manager already comes with a few clients included that we can see in the Clients tab in our server container.

Clients included in the server container

We have Google Analytics 4, Google Analytics, Universal Analytics, and recently, we also have the Measurement Protocol included.

Every incoming request to our server container gets processed by the appropriate client into the right format we can later use in our tags. 

The information that our client has passed is available to us in the server container under Event Data.

Event data for the page view entry

Our data is now being sent to our server container. Let’s create a tag to relay this information to the Google Analytics endpoint.

Sending Google Analytics 4 Tags

In our server container, go to TagsNew.

Creating a new tag in the server container

Although server-side tagging isn’t a new concept, this feature is relatively new to Google Tag Manager. Currently, there are a few server tags available, but they should increase in the future.

Let’s select Tag ConfigurationGoogle Analytics: GA4.

Creating a Google Analytics: GA4 tag

Here, we can overwrite the request coming in. We can change the measurement ID or event name, for example. We only want to relay the request for now and see how GTM server-side tagging works, so leave these unchanged.

Google Analytics: GA4 tag configuration

Click on Triggering.

Applying a trigger to the tag

Select the All Pages trigger, then click on Add.

Applying an all pages trigger

Create a name for this tag, then click on Save.

Naming and saving the Google Analytics: GA4 tag

While I named this tag “GA4 – Pageview”, it isn’t just for the page view entry. This tag relays any request that comes through the server-side instance since the All Pages trigger acts like an all-catch trigger.

Let’s try out the tag by clicking on Preview.

Entering preview mode for server containers

This opens another tab containing the debug information. Now, we need to send another request to our server-side instance, so that it gets relayed to Google Analytics.

Go to the client-side and refresh the website.

Reloading the website

Head back to our server-side instance, click on page_viewTags.

Tags fired by page view entry

The tag seems to work properly. Let’s check our Google Analytics account to confirm.

Click on ConfigureDebugView.

DebugView in Google Analytics

Great! We have the page view event that came in not from our website but was relayed through our server-side instance. 

What else can you do with Server-Side Tagging?

There is still so much more that you can do with Google Tag Manager server-side tagging. For example, you can send data to the Meta Conversions API via Google Tag Manager server-side. You can also update your domain or upgrade your container.

Update your Domain

If you don’t want to use the AppSpot domain provided by Google, you can change this default domain inside your Cloud Console configurations. 

We recommend that you use a subdomain of your website by following the steps for custom domain configurations provided by Google Developers. You can then change your server container URL by accessing your server-side container settings.

Go to AdminContainer Settings.

Accessing container settings

Simply replace the default domain URL with your created subdomain to finish upgrading your domain. However, since a subdomain is regarded as a separate website by Google, this option will incur additional costs. 

Upgrade your Container

Another thing to consider is to upgrade the Google Cloud instance for your GTM server container to be production-ready. Upgrading the instance would mean that the cloud machine will have the capacity to handle more than you are testing. 

If you decide to upgrade to the production version, submit a live version of your tags for both your server-side and client-side instances. 

Go back to Tag Manager and click on Submit

Submitting a live version

Finally, add a version name and click Publish

Publishing the live version

Summary

That’s how you set up Google Tag Manager server-side tagging. With server-side tracking, you have increased control over your data. 

Do you want to implement server-side tagging on a Shopify website? First, follow our guide on how to install Google Tag Manager and GA4 in Shopify

What aspects of server-side tracking made you want to switch from client-side tracking? What improvements to GTM server-side tagging would you like to see? Let us know in the comments below!

JOIN US!

Master Data & Analytics with Measuremasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more
guest
0 Comments
Inline Feedbacks
View all comments

Blog Categories

Want to find the Best Sources for Learning GTM? Subscribe & Get our FREE Resource Guide

Google Tag Manager FREE Resource Guide

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.