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.
- Visitor landsPage loads normally
- Script requestmetrics.example.com does not respond
- GA4 startsNo gtag or config runs
- Events sentpage_view and conversions never reach GA4
- Ads and reportsMissing or falling data
The page loads, but the script request to the custom domain fails, so every later step is lost.
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
Open DevTools on a funnel page
In Chrome, press F12 and open the Network tab. Tick Disable cache and reload the page.
Filter for the script
Type
gtag,gtmorcollectin the filter box. Note the domain each request uses.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.
Compare with the source
View the page source (Ctrl+U) and search for
googletagmanagerandgtag. Check the domain in the script tag or loader for typos and old hostnames.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.
<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>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.
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.
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.
Find where the tag is added
Check your analytics plugin (for example Site Kit or a GTM plugin), your theme's header settings and any header and footer scripts plugin. Search each for the old domain.
Replace the domain
Update or delete the custom script URL and save. If a plugin offers a first-party or proxy option, turn it off or enter a working domain.
Clear caches
Purge your caching plugin and CDN so visitors stop receiving the old HTML.
Check Customer events and the theme
In Settings > Customer events, review custom pixels. In Online Store > Themes > Edit code, search theme.liquid for the old domain.
Check Google & YouTube or other apps
If an app injects the script, check its settings for a custom domain or proxy and correct or disable it.
Edit custom code
Open Site settings > Custom code and also page-level settings under each page's settings. Replace the script URL with the Google one or a working domain, then publish.
Review Marketing integrations
Open Settings > Custom code and Marketing integrations. Remove or correct any snippet that points to the dead domain, then publish.
Check code injection
Open Settings > Developer Tools > Code Injection (Header and Footer). Fix the script URL and save.
Check tracking code fields
Look in Sites > Funnels (or Websites) > the funnel > Settings > Tracking Code (header and footer), and the same fields on individual pages. Replace the dead URL and republish.
Search the codebase
Search templates, includes and build config for the old hostname. Update it everywhere, including layouts used by checkout and thank-you pages.
Repair the proxy if you keep it
If you serve the script from your own domain, make sure DNS points to a live server, the TLS certificate is valid and the proxy forwards requests to Google.
How to confirm it's fixed
- 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
- 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.
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.
Related issues
- TRK-001GA4 tag missing from a funnel pageFix guide
- TRK-002GA4 tag missing site-wide after a theme or builder changeFix guide
- TRK-009GA4 script blocked by Content Security PolicyFix guide
- TRK-003Wrong GA4 measurement ID (staging or another client's property)Fix guide
- TRK-008gtag.js loaded but config command never calledFix guide
- TRK-014GA4 data stream web URL pointing to an old domainFix guide