Skip to content
Integration

Server-Side GTM for Consent-Aware Tracking

Taha Farhane· Founder, Arqam360 — building MENA consent + data infrastructure
February 4, 202610 min read
Read the full guide: How to Set Up Google Consent Mode v2 (Step-by-Step)

Server-side Google Tag Manager (sGTM) represents a fundamental architecture shift in how websites implement marketing tags. Instead of firing JavaScript tags directly in the visitor's browser — where they are vulnerable to ad blockers, browser privacy restrictions, and performance degradation — server-side GTM processes tag logic on a server container that you control. The browser sends a single first-party request to your server, and the server then dispatches events to Google Analytics, Meta, TikTok, and other platforms via their server-side APIs.

Why Server-Side GTM Matters in 2026

Client-side GTM has been the industry standard for tag management for over a decade, but the browser environment it relies on has changed dramatically. Ad blockers now filter requests to known tracking domains (blocking GTM-fired tags for 25-35% of desktop users), Safari's ITP limits cookie lifetimes to 7 days (collapsing attribution windows), and iOS ATT has an 85%+ opt-out rate (severely limiting pixel data from mobile devices). Each of these restrictions independently degrades data quality — combined, they create blind spots that make client-side-only tracking unreliable.

Step-by-Step Setup Guide

  • Step 1: In GTM, create a new server-side container. Google will provide a provisioning link for GCP Cloud Run (recommended) or manual deployment instructions for other cloud providers
  • Step 2: Deploy the server container — GCP Cloud Run is the simplest option (automatic scaling, pay-per-use). Budget approximately $30-100/month depending on traffic volume
  • Step 3: Configure a custom subdomain as your transport URL (e.g., sgtm.yourdomain.com). Set up DNS CNAME to point to your server container. This makes all requests appear as first-party traffic
  • Step 4: In your web container, update the GA4 configuration tag to use your transport URL instead of sending directly to google-analytics.com
  • Step 5: Install server-side tag templates: GA4 tag (built-in), Meta CAPI tag (Community Gallery), Google Ads conversion tag, and any other platform tags you need
  • Step 6: Configure consent-aware triggers in the server container — tags should only fire when the appropriate consent category has been granted
  • Step 7: Implement Google Consent Mode v2 in your web container using Arqam360 or another CMP — consent state must flow from the browser to the server container
  • Step 8: Test using GTM Preview mode (both web and server containers) and verify events are arriving at each platform

Consent-Aware Tag Firing

The most critical aspect of server-side GTM is implementing consent-aware tag firing correctly. Without proper consent integration, server-side GTM can actually create compliance problems — because the server fires tags outside the browser, violations are harder to detect and audit. The correct approach is to pass the visitor's consent state from the browser to the server container as part of every request, and use that consent state to gate which server-side tags fire.

Essential Server-Side Tag Templates

The GTM Community Gallery provides server-side tag templates for all major platforms. These templates handle the protocol translation between the GA4 measurement protocol (which your web container sends) and each platform's native server-side API. Install the templates that match your advertising platforms:

Best Practices for MENA Implementations

  • Always use a first-party subdomain for the transport URL — this is what makes server-side requests bypass ad blockers
  • Deploy to a cloud region close to your audience — GCP's me-central1 (Doha) or me-west1 (Tel Aviv) for MENA traffic
  • Implement consent mode signals end-to-end: CMP → web container → server container → tag firing conditions
  • Enable event deduplication between client-side and server-side events (using event_id matching)
  • Monitor server container health, latency, and costs through GCP/AWS dashboards
  • Test all consent states: granted, denied, and default (no interaction yet)
  • Set up alerting for server container errors and high latency — failed server-side events mean lost data
  • Consider Arqam360's server-side events as an alternative that provides the same functionality without managing server infrastructure
For most MENA businesses, Arqam360's server-side events can replace server-side GTM entirely — same functionality with zero infrastructure management. Choose sGTM only if you need custom tag logic that Arqam360 does not support.
Learn more in our guide: Integrations

Set up in minutes, not days

Arqam360 integrates with Google Consent Mode v2, GTM, GA4, and Meta/TikTok/Snap pixels automatically.

Start Free Trial

Stay updated

Get privacy compliance tips and Arqam360 updates delivered to your inbox.