Custom Subdomain for Your Tagging Server: Why It Matters | Adslytics | Adslytics

Server-Side Tracking How-To Guide

Setting Up a Custom Subdomain for Your Tagging Server (And Why It Matters)

By Muhammad Farooq · January 30, 2026 · 6 min read
Setting Up a Custom Subdomain for Your Tagging Server (And Why It Matters)

Why the Default Tagging Server URL Is Not Enough

When you first deploy a server-side GTM tagging server on Google Cloud Run, you get a default URL like sgtm-xxxx.run.app. This works technically — events are received and forwarded — but it does not give you the key benefit of server-side tracking: first-party context.

First-party context means the tagging server runs on your own domain (like collect.yoursite.com). This is essential for two reasons:

  1. Ad blocker resistance: ad blockers block known analytics domains. Your custom subdomain is not on any blocklist, so ad blocker users' events reach your server.
  2. First-party cookies: cookies set by a server at collect.yoursite.com are first-party cookies. Safari's Intelligent Tracking Prevention only restricts third-party cookies (set by domains other than the site the user is on). A cookie set by your server on your subdomain lasts the full duration you configure — typically 2 years.

What Subdomain to Use

Common naming conventions:

  • collect.yoursite.com — descriptive, clearly about data collection
  • analytics.yoursite.com — clear purpose
  • metrics.yoursite.com — neutral
  • t.yoursite.com — short and clean

Avoid using "tracking" in the subdomain name — some aggressive ad blocker configurations block subdomains containing "track" as a keyword.

Setting Up the Custom Subdomain

Step 1: Add a CNAME Record in Your DNS

  1. Log into your DNS provider (wherever your domain's DNS is managed — Cloudflare, GoDaddy, Namecheap, Route 53, etc.)
  2. Create a new CNAME record:
    • Name: collect (or whichever subdomain you chose)
    • Value: your Cloud Run service URL (e.g. sgtm-xxxx-uc.a.run.app) or Stape URL
    • TTL: 300 (5 minutes) for flexibility during setup, then increase to 3600+ once confirmed

Step 2: Add the Custom Domain in Cloud Run

  1. In Google Cloud Console: Cloud Run then your service then Domain Mappings
  2. Add Mapping: enter your custom subdomain (collect.yoursite.com)
  3. Google validates the DNS record and provisions an SSL certificate (takes 5-30 minutes)
  4. Status shows "Active" when ready

Step 3: Configure sGTM to Use the Custom Domain

  1. In your GTM server container Settings: set the "Default Container URL" to your custom subdomain
  2. In your web GTM Google Tag: update the server_container_url configuration parameter to point to https://collect.yoursite.com
  3. Publish the web GTM container

Verifying the Setup

  1. Visit https://collect.yoursite.com/healthy in a browser — if the server is running, you see a simple "ok" response
  2. In GTM web Preview Mode, browse your website and check the Network tab — GA4 requests should now go to collect.yoursite.com instead of analytics.google.com
  3. Check the sGTM Preview for incoming requests on your server container

Summary

A custom subdomain is not optional for effective server-side tracking — it is what makes the tracking first-party, ad-blocker resistant, and capable of setting cookies with full lifetimes. Set it up as part of your initial server-side GTM deployment, not as an afterthought.

See our Server-Side Tracking service for complete setup.

Need help setting up server-side tracking with a custom domain? 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 →