...
πŸš€ deploy sst cluster for google tag manager on ubuntu vps
Learn how to deploy sst cluster for google tag manager on ubuntu vps!

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

  1. Tagging Server (SST Cluster)
    • Handles live production traffic
    • Scales horizontally (2 β†’ 10+ instances)
    • Endpoint example:
      https://sst.yourdomain.com
    
  2. Preview Server (Separate)
    • Used for debugging / preview mode
    • Exactly ONE instance
    • Endpoint:
      https://preview.yourdomain.com
    
  3. 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:

  1. Receives event (e.g., pageview, conversion)
  2. Processes it through GTM server container
  3. Sends data to:
    • Google Analytics
    • Meta Pixel
    • TikTok
    • Custom APIs

πŸš€ Why Use an SST Cluster?

  1. First-party tracking (huge advantage)
    • Uses your domain (sst.yourdomain.com)
    • Improves data reliability
    • Bypasses browser restrictions (like ITP, ad blockers)
  2. Better performance
    • Browser sends 1 request instead of many
    • Server handles the rest
  3. Data control & privacy
    • You decide:
    • what gets sent
    • what gets removed
    • where it goes
  4. 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)

Launch 100% ssd ubuntu vps from $3. 19/mo!


Compare Ubuntu VPS Plans

KVM-SSD-1
KVM-SSD-8
KVM-SSD-16
KVM-SSD-32
CPU
1 Core
2 Cores
4 Cores
8 Cores
Memory
1 GB
8 GB
16 GB
32 GB
Storage
16 GB NVMe
128 GB NVMe
256 GB NVMe
512 GB NVMe
Bandwidth
1 TB
4 TB
8 TB
16 TB
Network
1 Gbps
1 Gbps
1 Gbps
1 Gbps
Delivery Time
⏱️ Instant
⏱️ Instant
⏱️ Instant
⏱️ Instant
Location
US/FR
US/FR
US/FR
US/FR
Price
$7.58*
$39.50*
$79.40*
$151.22*
KVM-SSD-1
CPU: 1 Core
Memory: 2 GB
Storage: 16 GB NVMe
1 TB
KVM-SSD-8
CPU: 2 Cores
Memory: 8 GB
Storage: 128 GB NVMe
4 TB
KVM-SSD-16
CPU: 4 Cores
Memory: 16 GB
Storage: 256 GB NVMe
8 TB
KVM-SSD-32
CPU: 8 Cores
Memory: 32 GB
Storage: 512 GB NVMe
16 TB

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:

  1. πŸ–₯️ Prepare Servers

    Run on ALL servers:

    apt update && apt upgrade -y
    apt install -y curl git unzip nginx
    
  2. 🐳 Install Docker

    curl -fsSL https://get.docker.com | bash
    usermod -aG docker $USER
    newgrp docker
    

    Install Docker Compose:

    apt install -y docker-compose
    
  3. πŸ“¦ Deploy GTM Server Container

    Create directory

    mkdir -p /opt/gtm-server
    cd /opt/gtm-server
    

    Create .env

    nano .env
    

    Example:

    CONTAINER_CONFIG=GTM-XXXXXXX
    RUN_AS_PREVIEW_SERVER=false
    PORT=8080
    

    πŸ‘‰ Replace GTM-XXXXXXX with your Server Container ID

    Create docker-compose.yml

    version: '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
    
  4. πŸ” 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.yml

    docker compose up -d
    
  5. 🌐 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
    
  6. πŸ”’ Enable SSL (Let’s Encrypt)

    apt install -y certbot python3-certbot-nginx
    
    certbot --nginx -d sst.yourdomain.com
    certbot --nginx -d preview.yourdomain.com
    
  7. 🌍 DNS Setup

    Create A records:

    sst.yourdomain.com β†’ PRODUCTION SERVER IP
    preview.yourdomain.com β†’ PREVIEW SERVER IP
    
  8. πŸ§ͺ Connect to Google Tag Manager

    Inside GTM Server Container UI:

    1. Go to Admin β†’ Container Settings
    2. Set:
    • Tagging Server URL:
    https://sst.yourdomain.com
    
    • Preview Server URL:
    https://preview.yourdomain.com
    
  9. πŸš€ 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
  10. πŸ“Š Health Check & Monitoring

    Test:

    curl http://127.0.0.1:8080/healthz
    

    Expected:

    ok
    
  11. 🧠 Performance Optimization

    Enable caching headers in Nginx:

    proxy_cache_valid 200 10m;
    

    Increase container resources

    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
    
  12. πŸ” Security Hardening

    Firewall

    ufw allow 80
    ufw allow 443
    ufw enable
    

    Restrict preview server access (recommended)

    location / {
        allow YOUR_IP;
        deny all;
    }
    
  13. πŸ“ˆ 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.com loads
  • [ ] https://preview.yourdomain.com loads
  • [ ] GTM preview mode connects successfully
  • [ ] /healthz returns 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

Launch 100% ssd ubuntu vps from $3. 19/mo!

Conclusion

You now know how to deploy SST cluster for Google Tag Manager on Ubuntu VPS.

Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg