How to Set Up Server-Side Google Tag Manager (GTM) Step-by-Step
Learn how to set up Server-Side Google Tag Manager (GTM) to improve tracking accuracy, boost website speed, and enhance data privacy. This step-by-step guide walks you through the entire process, from creating a GTM container to setting up a cloud server and testing your setup. Perfect for marketers and website owners looking to take their tracking strategy to the next level! 🚀
3/9/20254 min read


How to Set Up Server-Side Google Tag Manager (GTM) Step-by-Step
Introduction
Tracking website visitors and their actions is essential for businesses that want to improve their marketing and sales. Most websites use Google Tag Manager (GTM) to manage tracking codes for tools like Google Analytics and Facebook Pixel.
However, traditional tracking methods rely on client-side tracking, which has problems like ad blockers, privacy restrictions, and slow website performance.
This is where Server-Side Google Tag Manager (Server-Side GTM) helps. Instead of running tracking scripts on the user’s browser, data is first sent to your own server, processed, and then forwarded to tools like Google Analytics.
In this guide, we will explain how to set up Server-Side GTM step by step, in a way that even a 10-year-old can understand.
What is Server-Side GTM?
Most websites use client-side tracking, which means that tracking scripts (like Google Analytics) run on the user’s browser. However, this method has several problems:
Ad blockers can block tracking scripts, preventing data collection.
Privacy-focused browsers like Safari limit how long cookies can track users.
Too many tracking scripts can slow down your website.
Server-side tracking solves these issues by sending data first to your own server before forwarding it to third-party tools. This improves accuracy, security, and website speed.
Example: Think of Server-Side GTM Like a Mail Sorting Center
Imagine you order a package online. Normally, the delivery company would send the package directly to your house, but sometimes packages get lost or take too long to arrive.
Now, imagine that instead of delivering the package directly, all packages first go to a sorting center. At the center, staff check the packages, remove unnecessary items, and then forward them safely to their destination.
Server-Side GTM works the same way. Instead of sending data directly from the user’s browser to Google Analytics or Facebook, it first goes to your own server, where it is processed and then sent securely.
Benefits of Server-Side GTM
1. More Accurate Data
Since data is sent from your server, it is less likely to be blocked by ad blockers or privacy settings.
2. Faster Website Speed
With fewer tracking scripts running on the browser, websites load faster, improving SEO rankings and user experience.
3. Better Data Security
You have more control over user data and can filter out sensitive information before sending it to third-party platforms.
4. Improved Privacy Compliance
Many countries have strict privacy laws (like GDPR). Server-side tracking helps ensure that you only share necessary data while protecting user privacy.
Step-by-Step Guide to Setting Up Server-Side GTM
Step 1: Create a Server-Side GTM Container
Go to Google Tag Manager (tagmanager.google.com).
Click "Create Account" and enter your website details.
Choose "Server" as the container type instead of "Web".
Click "Create" to set up your server-side container.
Step 2: Set Up a Cloud Server to Host GTM
Server-Side GTM needs a server to process data before sending it to third-party tools. The easiest way is to use Google Cloud Platform (GCP).
Go to Google Cloud Console (console.cloud.google.com).
Create a new project by clicking on the project dropdown and selecting “New Project.”
Enable billing – Google Cloud gives free credits, but you may need to add a payment method.
Go to the GTM Server-Side Container Setup page in Google Tag Manager.
Click "Automatic Provisioning" – This will create a new server in Google Cloud for you.
Once done, Google Cloud will provide a server URL where your GTM container is hosted.
Step 3: Update GTM Settings in Your Website’s GTM Container
Go back to Google Tag Manager and open your Web Container.
Click on Admin > Container Settings.
Find the option "Enable enhanced measurement" and make sure it is enabled.
Go to Tags > New Tag and create a Google Analytics 4 (GA4) Tag.
In the Tag Configuration, select "Send data to Server-Side GTM" and enter the server URL from Google Cloud.
Click Save and Publish.
Step 4: Set Up a Custom Domain (Optional but Recommended)
By default, Google Cloud assigns a random URL for your server. It is better to use a custom subdomain like tracking.yourwebsite.com for better branding and security.
Go to your domain provider (GoDaddy, Namecheap, etc.).
Create a new CNAME record pointing to your Google Cloud server.
Update GTM settings to use your custom domain instead of the default one.
Step 5: Test Your Server-Side GTM Setup
Before going live, it’s important to test if your server-side GTM is working correctly.
Go to Google Tag Manager > Preview Mode.
Visit your website and interact with it (click buttons, fill out forms, etc.).
Check the server logs in Google Cloud to see if data is being received.
Check Google Analytics to confirm that the data is reaching the correct location.
Common Mistakes to Avoid
1. Not Hosting the Server Properly
If the server is not set up correctly, tracking may fail or slow down. Always test after setup.
2. Forgetting to Update GTM Settings
Make sure you change tracking URLs to point to your server-side container instead of sending data directly to Google Analytics.
3. Ignoring Privacy Compliance
Server-side GTM allows you to filter out unnecessary data before sending it to third parties. This helps protect user privacy and comply with GDPR laws.
Should You Use Server-Side GTM?
If you have a small blog or simple website, traditional GTM may be enough.
However, if you run an e-commerce store, membership site, or any business that relies on tracking for advertising and conversions, then server-side GTM is highly recommended.
Final Thoughts
Setting up Server-Side Google Tag Manager can significantly improve tracking accuracy, website speed, and data privacy.
By moving tracking from the browser to your own server, you get better control over user data and ensure that important analytics and marketing tools receive accurate information.
If you’re serious about improving your tracking strategy, now is the time to switch to Server-Side GTM.
Would you like help setting up server-side tracking?
Get in touch with us:
Email: connect@ecommidea.com
WhatsApp: wa.me/919839618999