
GTM not firing after server migration
Did you change your server? And after changing your server, the Google Tag Manager not firing properly? Read how to solve it.
Changing web hosting or moving to a new server is a major milestone for any website. While a server migration can boost speed, security, and reliability, it often triggers unexpected technical hiccups most notably with tracking and measurement tools like Google Tag Manager (GTM).
If your GTM tags suddenly stopped firing, are triggering duplicate events, or show zero data in Google Analytics 4 (GA4) after a server change, don’t panic. This guide walks you through the exact reasons why server migrations break GTM and the step-by-step solutions to restore your tracking fast. Contact Us
Why Changing Your Server Breaks Google Tag Manager
When you migrate your website to a new server, several core configurations change under the hood:
IP Addresses & DNS Records: Domain Name System (DNS) propagation delays can temporarily route requests to old server configurations or block tracking scripts.
Server Caching & CDN Layers: Aggressive server-side caching (e.g., LiteSpeed, Varnish, Cloudflare) can serve outdated HTML pages without the updated container code.
Security & Firewall Restrictions: New Web Application Firewalls (WAFs) or Content Security Policies (CSPs) often flag GTM network requests as potential threats and block them.
PHP / Server Environment Updates: Migrating to a newer PHP version or custom server setup might alter script injection plugins,
wp-cron, or header file hooks.
Step-by-Step Troubleshooting Checklist For GTM Not Firing After Server Migration
Follow these verified steps in order to diagnose and resolve GTM firing failures on your new server:
Step 1: Inspect the Site with Tag Assistant & Developer Tools
Open Google Tag Assistant and connect your domain URL.
Check if the GTM container ID (
GTM-XXXXXXX) connects successfully.Open your browser’s Developer Tools (
F12or Right-Click > Inspect).Navigate to the Console tab and check for red error messages such as:
Refused to load the script '[https://www.googletagmanager.com/gtm.js](https://www.googletagmanager.com/gtm.js)' because it violates the following Content Security Policy directive...Navigate to the Network tab, filter by
gtm.jsorcollect, and ensure the HTTP status code returns200 OK(and not403 Forbiddenor404 Not Found).
Step 2: Clear All Caching Layers (Server, CDN, & WordPress)
A common post-migration issue occurs when the browser or server delivers a cached HTML copy missing the GTM container script.
Server-Level Cache: Purge cache directly inside cPanel, LiteSpeed Web Server, NGINX FastCGI, or Varnish.
CDN Cache: If you use Cloudflare or another CDN, navigate to your dashboard and perform a Purge Everything.
Plugin Cache: Clear caching plugins like WP Rocket, LiteSpeed Cache, or W3 Total Cache.
Step 3: Check Content Security Policy (CSP) & CORS Headers
If your new server enforces strict security headers by default, it will block outgoing connections to Google’s tracking servers.
The Fix: Update your server configuration (.htaccess, NGINX config, or security plugin) to allow GTM domains:
Step 4: Verify Server-Side GTM Setup (If Applicable)
If you are using Server-Side Google Tag Manager (hosting your container on Cloud Run, Stape, or AWS):
Check Your Custom Domain DNS Records: Ensure the
AorAAAArecord pointing your tracking subdomain (e.g.,metrics.yourdomain.com) matches your new server IP.SSL Certificate Issues: Verify that your custom tracking subdomain has a valid, active SSL certificate on the new server.
Request Headers: Confirm that your web server forwards essential client headers (
X-Forwarded-For,User-Agent,Host) to the tagging server container.
Step 5: Re-verify Script Injection Method
If your GTM script was added directly into your theme files (header.php / footer.php) or injected via a WordPress plugin:
Ensure the
<head>code snippet is placed as high as possible inside<head>...</head>.Ensure the
noscriptfallback iframe snippet is placed immediately after the opening<body>tag.If using a plugin, deactivate and reactivate the GTM plugin to ensure hook execution order hasn’t been displaced by new server configurations.
Quick Diagnostic Summary Table For If GTM Not Firing after server migration
| Error Symptom | Likely Cause | Solution |
| GTM Not Detected in Console | Old cache being served / DNS propagation delay | Purge CDN/Server Cache; flush local DNS (ipconfig /flushdns). |
| CSP / Red Error in Console | Strict Content Security Policy on new server | Add GTM domains to script-src and connect-src in CSP. |
HTTP 403 Forbidden on gtm.js | WAF / ModSecurity blocking outgoing requests | Whitelist GTM User-Agent or IP ranges in Cloudflare/ModSecurity. |
| Tags Fail to Fire in Preview Mode | Tracking blocked by ad-blocker or strict server headers | Test in Clean Incognito Mode without browser extensions. |
