Skip to content
FunnelGuard

Fix guide by FunnelsGuard

GA4 script loaded from a wrong or dead custom domain: fix

TRK-010High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

By default, the GA4 script loads from https://www.googletagmanager.com. Some sites load it from their own domain instead, for example https://metrics.example.com/gtag/js?id=G-XXXXXXX. This is common with server-side Google Tag Manager (a tagging server you run or rent), a CDN or proxy, or a plugin that serves the script from your own domain.

Why it costs you leads or sales

The page itself still looks fine, so nobody notices. But GA4 gets no page views, no events and no conversions from the affected pages. Reports go quiet, and anything built on GA4 data suffers: imported Google Ads conversions, audiences and bidding signals. You may cut budget on campaigns that are actually working, or let broken ones run unchecked.

Where the tracking chain breaks
  1. Visitor landsPage loads normally
  2. Script requestmetrics.example.com does not respond
  3. GA4 startsNo gtag or config runs
  4. Events sentpage_view and conversions never reach GA4
  5. Ads and reportsMissing or falling data

The page loads, but the script request to the custom domain fails, so every later step is lost.

Recorded GA4 sessions around a dead script domainExample numbers
Recorded GA4 sessions around a dead script domain (example)Day before: 1,200 sessions per day; Day it breaks: 300 sessions per day; Day after: 0 sessions per day; Week later: 0 sessions per day04609201,20030000Day beforeDay it breaksDay afterWeek latersessions per day

Example: illustrative numbers. Real traffic stays steady, but recorded sessions drop to near zero the day the custom domain stops responding.

How to check if your site has it

Find the failing script request
  1. Open DevTools on a funnel page

    In Chrome, press F12 and open the Network tab. Tick Disable cache and reload the page.

  2. Filter for the script

    Type gtag, gtm or collect in the filter box. Note the domain each request uses.

  3. Look for failures

    Red rows with a status such as 404, 502, 503 or (failed) net::ERR_NAME_NOT_RESOLVED or ERR_CERT_DATE_INVALID mean the domain is dead or misconfigured. Open the Console tab too, which shows the same errors.

  4. Compare with the source

    View the page source (Ctrl+U) and search for googletagmanager and gtag. Check the domain in the script tag or loader for typos and old hostnames.

  5. Test the URL directly

    Paste the script URL into a new tab. A working script returns JavaScript. An error page, timeout or certificate warning confirms the problem.

How to fix it

You have two options. Restore the custom domain (fix DNS, the certificate or the tagging server), or switch the script back to Google's default domain. The second is the fastest way to get data flowing again.

Standard GA4 snippet loading from Googlehtml
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXX');
</script>
Where to change the script domain
  1. Check the Google tag settings

    Open your Google tag (or GA4 Configuration tag). If you set a server container URL under Configuration settings (server_container_url / transport_url), correct it or remove it so hits go to Google.

  2. Fix the container snippet on the site

    If the GTM snippet on the site loads from a custom domain, replace it with the one from Admin > Install Google Tag Manager, which uses www.googletagmanager.com. Publish the container.

  3. Check the tagging server

    If you use server-side GTM, open the server container, Admin > Container Settings > Tagging server URLs. Make sure the domain exists in DNS and has a valid certificate.

How to confirm it's fixed

Confirmation checks
  • The script request in the Network tab returns status 200 with no red rows.
  • There are no ERR_NAME_NOT_RESOLVED or certificate errors in the Console.
  • A request to /g/collect (or your tagging server) returns 204 or 200 on page load.
  • In GA4, Reports > Realtime shows your own visit within a minute or two.
  • In Admin > DebugView (or GTM Preview mode), the page_view event appears.
  • Key funnel pages and the thank-you page all pass, not just the home page.

How to prevent it happening again

Prevention
  • Keep a list of every custom domain used for tracking, with the registrar, DNS host and renewal date.
  • Turn on auto-renew for the domain and the certificate.
  • Add tracking checks to your migration checklist, so moving a server or changing DNS includes testing the script URL.
  • Avoid hard-coding old hostnames in several places. Use one setting or one tag manager container.
  • Run an automated check on key pages so a failing script is caught in hours, not weeks.

How FunnelGuard handles this

FunnelGuard detects this today. It uses a broken-resources check (no_broken_resources): a robot visitor loads your funnel pages on a schedule and flags script or other resource requests that fail, such as a script that errors or times out. A failing GA4 script URL on a custom domain shows up this way. If the failure repeats from a second region, you get one alert with a screenshot and a likely cause.

Script domain before and after the fix

Before

  • Page requests the script from a dead custom domain
  • Console shows ERR_NAME_NOT_RESOLVED
  • GA4 Realtime shows nothing
  • Ads conversions imported from GA4 fall

After

  • Script loads with status 200
  • Console is clean
  • Realtime shows your visit
  • Events and conversions flow again

Questions people ask

Why is my GA4 script not loading from my custom domain?

The most common causes are an expired or deleted DNS record, a tagging server that was shut down or moved, an expired TLS certificate, or a typo in the hostname. Open the Network tab, find the failing request and read its error. That error tells you which of these it is.

How do I check whether gtag.js is loading?

Open DevTools with F12, go to the Network tab, reload the page and filter for gtag or gtm. A status of 200 means it loaded. A red row, 404, 5xx or net::ERR_ message means it failed.

Can I switch GA4 back to the Google domain?

Yes. Replace the custom script URL with https://www.googletagmanager.com/gtag/js?id=YOUR_ID, or reinstall the Google Tag Manager snippet from Admin > Install Google Tag Manager. If you use server-side tagging, also remove the custom server container URL from your Google tag settings.

Will I lose GA4 data while the script is broken?

Yes. GA4 can only record what the browser sends, and a failed script sends nothing. Data from the broken period generally cannot be recovered, so fix it quickly.

Why did GA4 stop tracking after I moved my site or server?

A migration often changes DNS or removes a subdomain that served the tracking script. If the page code still points to the old hostname, the request fails. Search your templates and tag manager settings for the old domain and update it.

Does FunnelGuard detect a broken GA4 script domain?

Yes. Its broken-resources check loads your funnel pages and flags script requests that fail. You get an alert with a screenshot and a likely cause after a second-region recheck.

Do I need a custom domain for GA4 at all?

No. The default Google domain works for most sites. A custom domain is mainly used with server-side tagging or to serve scripts first-party, and it adds upkeep you must maintain.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: no_broken_resources.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.