
This article demonstrates how to deploy SST cluster for Google Tag Manager on Ubuntu VPS.
We will cover how to deploy a self-hosted Server-Side Tagging (SST) cluster for Google Tag Manager (with preview server) on Ubuntu VPS.
What is an SST Cluster for Google Tag Manager?
An SST (Server-Side Tagging) cluster for Google Tag Manager is a group of server instances that run your server-side GTM container to process tracking events on your infrastructure instead of in the browser.
π§ Simple Explanation
Instead of this (traditional tracking):
User Browser β Facebook / Google / TikTok (direct)
You run:
User Browser β YOUR SST Server β Third-party platforms
π The SST cluster = your tracking βmiddle layerβ
π§± What βClusterβ Means
A cluster is simply:
- Multiple servers (or pods in Kubernetes)
- Running the same GTM server container
- Behind a load balancer / ingress
- Auto-scaling based on traffic
π Core Components
-
Tagging Server (SST Cluster)
- Handles live production traffic
- Scales horizontally (2 β 10+ instances)
- Endpoint example:
https://sst.yourdomain.com
-
Preview Server (Separate)
- Used for debugging / preview mode
- Exactly ONE instance
- Endpoint:
https://preview.yourdomain.com
-
Container (GTM Server Container)
- Your actual tagging logic lives here
- Configured inside Google Tag Manager
βοΈ What the SST Cluster Actually Does
When a request hits your SST endpoint:
- Receives event (e.g., pageview, conversion)
- Processes it through GTM server container
- Sends data to:
- Google Analytics
- Meta Pixel
- TikTok
- Custom APIs
π Why Use an SST Cluster?
-
First-party tracking (huge advantage)
- Uses your domain (
sst.yourdomain.com) - Improves data reliability
- Bypasses browser restrictions (like ITP, ad blockers)
- Uses your domain (
-
Better performance
- Browser sends 1 request instead of many
- Server handles the rest
-
Data control & privacy
- You decide:
- what gets sent
- what gets removed
- where it goes
-
Scalability
- Cluster allows:
- high traffic handling
- auto-scaling under load
π Real Example Flow
Visitor lands on site
β
Browser sends event β sst.yourdomain.com
β
SST Cluster processes request
β
Sends:
β Google Analytics
β Meta Ads
β CRM / API
This guide gives you a production-ready, multi-server setup:
- Tagging Server (Production)
- Preview Server (Debug/Preview Mode)
- Optional: Load balancer / scaling layer
π§± Architecture Overview
[ Browser ]
β
[ DNS: sst.yourdomain.com ] βββΊ [ Tagging Server Cluster ]
β
[ DNS: preview.yourdomain.com ] βββΊ [ Preview Server ]
- sst.yourdomain.com β handles live traffic
- preview.yourdomain.com β used ONLY for GTM preview/debug
- Both run the GTM Server container
βοΈ Requirements
- Ubuntu 22.04/Ubuntu 24.04 VPS (2+ servers recommended)
- Domain + DNS access
- Docker + Docker Compose
- Reverse proxy (Nginx or Caddy)
- SSL (Letβs Encrypt)
Compare Ubuntu VPS Plans
How to Deploy SST Cluster for Google Tag Manager on Ubuntu VPS
To deploy SST cluster for Google Tag Manager on Ubuntu VPS, follow the steps below:
-
π₯οΈ Prepare Servers
Run on ALL servers:
apt update && apt upgrade -y apt install -y curl git unzip nginx
-
π³ Install Docker
curl -fsSL https://get.docker.com | bash usermod -aG docker $USER newgrp docker
Install Docker Compose:
apt install -y docker-compose
-
π¦ Deploy GTM Server Container
Create directory
mkdir -p /opt/gtm-server cd /opt/gtm-server
Create
.envnano .env
Example:
CONTAINER_CONFIG=GTM-XXXXXXX RUN_AS_PREVIEW_SERVER=false PORT=8080
π Replace
GTM-XXXXXXXwith your Server Container IDCreate
docker-compose.ymlversion: '3' services: gtm-server: image: gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable restart: always env_file: - .env ports: - "127.0.0.1:8080:8080"Start container
docker compose up -d
-
π Deploy Preview Server
On your preview VPS:
mkdir -p /opt/gtm-preview cd /opt/gtm-preview nano .env
CONTAINER_CONFIG=GTM-XXXXXXX RUN_AS_PREVIEW_SERVER=true PORT=8080
Same
docker-compose.ymldocker compose up -d
-
π Configure Nginx Reverse Proxy
Production (sst.yourdomain.com)
nano /etc/nginx/sites-available/sst
server { server_name sst.yourdomain.com; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }Preview (preview.yourdomain.com)
nano /etc/nginx/sites-available/preview
server { server_name preview.yourdomain.com; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } }Enable configs
ln -s /etc/nginx/sites-available/sst /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-available/preview /etc/nginx/sites-enabled/ nginx -t && systemctl reload nginx
-
π Enable SSL (Letβs Encrypt)
apt install -y certbot python3-certbot-nginx
certbot --nginx -d sst.yourdomain.com certbot --nginx -d preview.yourdomain.com
-
π DNS Setup
Create A records:
sst.yourdomain.com β PRODUCTION SERVER IP preview.yourdomain.com β PREVIEW SERVER IP
-
π§ͺ Connect to Google Tag Manager
Inside GTM Server Container UI:
- Go to Admin β Container Settings
- Set:
- Tagging Server URL:
https://sst.yourdomain.com
- Preview Server URL:
https://preview.yourdomain.com
-
π Scale to Cluster (Load Balancer)
For multiple production nodes:
Option A β Nginx Load Balancer
upstream gtm_cluster { server 10.0.0.1:8080; server 10.0.0.2:8080; } server { server_name sst.yourdomain.com; location / { proxy_pass http://gtm_cluster; } }Option B β Cloudflare / External LB
- Use multiple origin IPs
- Enable health checks
- Sticky sessions NOT required
-
π Health Check & Monitoring
Test:
curl http://127.0.0.1:8080/healthz
Expected:
ok
-
π§ Performance Optimization
Enable caching headers in Nginx:
proxy_cache_valid 200 10m;
Increase container resources
deploy: resources: limits: cpus: '2' memory: 2G -
π Security Hardening
Firewall
ufw allow 80 ufw allow 443 ufw enable
Restrict preview server access (recommended)
location / { allow YOUR_IP; deny all; } -
π Logging
docker logs -f gtm-server
π§© Optional Enhancements
- Redis cache layer
- Geo routing
- WAF (Cloudflare)
- Auto-scaling (Kubernetes instead of Docker)
β Final Validation Checklist
- [ ]
https://sst.yourdomain.comloads - [ ]
https://preview.yourdomain.comloads - [ ] GTM preview mode connects successfully
- [ ]
/healthzreturns OK - [ ] SSL valid
- [ ] DNS resolving correctly
β‘ Production Notes (Important)
- NEVER expose preview server publicly without restriction
- Use separate VPS for preview to avoid latency spikes
- Keep GTM container image updated:
docker compose pull && docker compose up -d
π§ Summary
You now have:
- Fully self-hosted GTM Server-Side Tagging
- Dedicated Preview server
- Scalable cluster architecture
- Secure, production-ready deployment
Conclusion
You now know how to deploy SST cluster for Google Tag Manager on Ubuntu VPS.









