Server-Side GA4: Route GA4 Through Your Own Server | Adslytics | Adslytics

Server-Side Tracking How-To Guide

Server-Side GA4: How to Route Google Analytics 4 Through Your Own Server

By Muhammad Farooq · February 1, 2026 · 8 min read
Server-Side GA4: How to Route Google Analytics 4 Through Your Own Server

What Server-Side GA4 Means

Standard GA4 sends data directly from the user's browser to Google's servers at analytics.google.com. Server-side GA4 means routing that data through your own sGTM server first — before it reaches Google — at a URL like collect.yoursite.com.

This adds a layer you control between the user's browser and Google Analytics, with several practical benefits.

Benefits of Server-Side GA4

  • Ad blocker resistance: GA4 requests go to your domain (not analytics.google.com which is blocked by many ad blockers)
  • First-party cookies: the _ga cookie is set server-side, bypassing Safari ITP's 7-day restriction
  • Data control: your server receives the raw event before GA4 does — you can redact PII, add custom parameters, or filter events before forwarding
  • Data enrichment: add server-side data to events that is not available in the browser (e.g. CRM customer tier, server-confirmed purchase amounts)
  • Reliable data: server-side events are more reliable than browser-side events because they are not affected by JavaScript errors or slow page loads

How the Data Flow Changes

Before server-side GA4:

Browser → analytics.google.com/g/collect (blocked by ~30% of ad blockers)

After server-side GA4:

Browser → collect.yoursite.com/g/collect (your server, first-party, not blocked) → Google Analytics servers

Setting Up Server-Side GA4

Step 1: In Web GTM — Modify the Google Tag

  1. Open your Google Tag in web GTM (the GA4 configuration tag)
  2. Under "Configuration Settings", add a new field: server_container_url
  3. Value: https://collect.yoursite.com (your sGTM custom subdomain)
  4. Save and publish the web GTM container

This single change causes the GA4 JavaScript library to send all its events to your sGTM server instead of directly to Google Analytics.

Step 2: In sGTM — Configure the GA4 Client

  1. In your server GTM container: Tags then New then GA4 Client (this is already present if you set up sGTM previously)
  2. The GA4 client listens for incoming GA4 events and makes them available to tags in the server container
  3. Configure cookie settings: enable server-side cookie setting, set domain to your root domain, set expiration to 63072000 seconds (2 years)

Step 3: In sGTM — Configure the GA4 Tag (Forward to Google)

  1. Add a GA4 tag in sGTM: Tags then New then Google Analytics GA4
  2. Set Measurement ID to your GA4 property's G-XXXXXXXXXX
  3. Trigger: "All Events" (forward all received events to GA4)
  4. This tag takes the events received by the GA4 client and forwards them to Google Analytics

Data Redaction and Enrichment

Between receiving the event (GA4 client) and forwarding it (GA4 tag), your sGTM server can transform the data:

  • Redact email addresses: if your data layer inadvertently includes raw email addresses, sGTM can strip them before forwarding to GA4
  • Add custom parameters: if you have CRM data (customer lifetime value, subscription tier), you can add it to events via a Firestore lookup or custom endpoint
  • Filter internal traffic: use your own logic to filter out office IP addresses server-side rather than relying on GA4's internal traffic filters

Verifying Server-Side GA4 Works

  1. In Chrome DevTools Network tab: filter for requests to collect.yoursite.com — you should see GA4 events (URLs containing /g/collect)
  2. Confirm requests are NOT going directly to analytics.google.com (at least for the initial hit — the measurement URL is changed)
  3. In GA4 DebugView: enable GA4 debug mode and verify events appear in the DebugView panel with expected parameters
  4. Check sGTM Preview for incoming events matching your browsing activity

Summary

Server-side GA4 routing is the central piece of any server-side tracking implementation — it redirects all GA4 data through your own infrastructure, delivering ad blocker resistance, longer cookie lifetimes, and data control. The configuration change in web GTM is a single parameter addition; the main work is setting up the sGTM infrastructure correctly.

See our Server-Side Tracking service for complete implementation.

Ready to route GA4 through your own server? Contact Adslytics.

Need expert tracking setup?

Our Google Tag Manager experts have delivered 500+ tracking setups with a 98% success rate.

Get a Free Consultation →
← Back to Blog
Muhammad Farooq

Author

Muhammad Farooq GTM & Analytics Expert · Adslytics Founder

Tracking specialist with 10+ years of experience in Google Tag Manager, GA4, Server-Side Tracking, and Google Ads. Founder of Adslytics — a dedicated analytics agency with a 98% success rate across 232+ projects on Upwork.

Top Rated Plus LinkedIn Visit the author's profile →