Server-Side Tracking In Google Tag Manager
Google introduced server-side tagging in 2020. By implementing a server container in Google Tag Manager (GTM) in conjunction with your existing web containers, you can measure user activity on your website wherever it happens. Make sure you familiarize yourself with what Google Tag Manager server-side tracking is and its benefits, before proceeding with the tag configuration, to make sure its right for your website needs.
If you haven’t had a chance to set up your GTM server container and Google Cloud Platform (GCP), read our blog here.
The tagging configuration we will cover in our blog, involves setting up the following:
- Client container configuration
- Variable configuration
- Trigger configuration
- Tag configuration
- Setting up client configuration
- Debugging your server-side tag
Client Container Configuration
1. After setting up your GCP, open the Server container in GTM and go to the Admin tab
2. Go to User Management and confirm you have Publish permissions in the server container
3. Return to your GTM workspace and navigate to the Clients tab in the left-hand menu
4. Click New to create our GA4 client
5. Name your Client Configuration “GA4”
6. Click on the Client Configuration area to open the different Client Type options
7. Select the Google Analytics: GA4 client option
8. Click Save
Variable Configuration
1. Navigate to the Variable tab in the left-hand menu
2. Click Configure in the Built-In Variables section and enable Client Name and Event Name
3. Once both of these variables are enabled, click the “X”
Trigger Configuration
1. Navigate to the Trigger tab on the left-hand menu
2. Click New
3. Name the Trigger - GA4 Server Side Trigger
4. Click the Trigger Configuration area to select a Trigger Type and click Custom
5. Select This trigger fires on - Some events and have your condition = Client Name equals GA4 to connect it to the GA4 Client we just configured
6. Once your trigger configuration looks like this, click Save
Tag Configuration
1. Navigate to the Tag tab in the left-hand menu
2. Click New
3. Name the Tag – GA4 Tag Server Side
4. Click the Tag Configuration area and click the Google Analytics: GA4 Tag Type
5. Enter your Measurement ID from the GA4 Property’s Data stream
6. Add the GA4 Server Side Trigger we configured under the Trigger Configuration section
7. Click Save
Setting Up Your Configuration Tag
The next step to configuring our server-side tags is to connect our server container with our web container using our GA4 Configuration tag. The GA4 configuration tag connects our GTM container with a GA4 property through a specific data stream’s measurement ID. We also need to indicate the server URL we created in our Google Cloud Platform.
1. Go to your web container and open your GA4 Configuration tag in the web container you want to connect
2. Click the send to server container check box
3. Input the server container URL we configured earlier
4. Click Save
Debugging Your Server-Side Tag
Debugging the tag requires enabling Preview mode in both the web and server containers.
Server Preview Mode
1. Open the server container Preview mode
2. You will notice that the URL of the new tab in your browser https://analytics.getfishtank.ca/ which we set it up in the first section of this work instruction. You should see an empty tag assistant summary dashboard
3. To test our Server tag, we need to open our web container and load the tag assistant to firm our GA4 Configuration tag in GTM to ensure that page load is also being sent to the server container
Web Preview Mode
1. In another tab, open the same property’s web container
2. Click Preview in the Overview section of the container you want to debug
3. Enter the URL of your website where we are testing the server-side tags
4. The page load itself should be enough to fire the GA4 server-side tag we just configured
5. Return to the server-side tag assistant to check if it fired
In Closing
Server-side tagging introduced a new layer of functionality for measuring events and collecting user data using Google Analytics. The tag configuration we covered in this blog will now allow you to send data from your website to a server on your Google Cloud Platform where a GTM instance is virtually loaded. The complexity of setting up server-side tagging can be intimidating, but our friendly team of Analytics experts are ready to help! Reach out to us at [email protected].
Until then, happy tracking!