Skip to main content

Digital Marketing

Need More Customers Online? Book a FREE Consultation
Book Now
PPC Management Google Ads

GTM not firing after server migration

GTM not firing after server migration

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

  1. Open Google Tag Assistant and connect your domain URL.

  2. Check if the GTM container ID (GTM-XXXXXXX) connects successfully.

  3. Open your browser’s Developer Tools (F12 or Right-Click > Inspect).

  4. 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...

  5. Navigate to the Network tab, filter by gtm.js or collect, and ensure the HTTP status code returns 200 OK (and not 403 Forbidden or 404 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):

  1. Check Your Custom Domain DNS Records: Ensure the A or AAAA record pointing your tracking subdomain (e.g., metrics.yourdomain.com) matches your new server IP.

  2. SSL Certificate Issues: Verify that your custom tracking subdomain has a valid, active SSL certificate on the new server.

  3. 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 noscript fallback 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 SymptomLikely CauseSolution
GTM Not Detected in ConsoleOld cache being served / DNS propagation delayPurge CDN/Server Cache; flush local DNS (ipconfig /flushdns).
CSP / Red Error in ConsoleStrict Content Security Policy on new serverAdd GTM domains to script-src and connect-src in CSP.
HTTP 403 Forbidden on gtm.jsWAF / ModSecurity blocking outgoing requestsWhitelist GTM User-Agent or IP ranges in Cloudflare/ModSecurity.
Tags Fail to Fire in Preview ModeTracking blocked by ad-blocker or strict server headersTest in Clean Incognito Mode without browser extensions.

Author

almuti Sharfuddin

Leave a comment

Your email address will not be published. Required fields are marked *