How do I find the broken links that send visitors to my 404 page?

Load the tracking snippet on your 404 page, add a goal for a named event called 404, and call postdeploy.track('404') from that page. The goal's conversions by page then list the broken paths, and by referrer the sites that sent people there. Analytics records only the referring host, so you still have to find the exact link on that site.

Last updated 26 November 2026. By Paul Badarau.

A fictional documentation site, quillguide.example, renames /docs/setup to /docs/install in a deploy and forgets the redirect. Other sites still link to the old path. A week later, PostDeploy Analytics shows 52 hits on the 404 goal for /docs/setup, and most of them came from forum.example.

To set that up:

  1. Make sure the 404 page loads the snippet. Analytics counts a page when its script runs, so if your host serves its own error page, add the snippet there or nothing is recorded.
  2. Serve the 404 page at the address that was requested. Analytics records the path of the page the script runs on, so a redirect to /404 turns every broken path into /404.
  3. Ask an Owner or Administrator to add a goal for the named event 404 in the Project. Do this before the code ships, because Analytics records a named event only when the Project has a goal with that name.
  4. In the 404 template, send the event once the snippet has run: document.addEventListener('DOMContentLoaded', function () { postdeploy.track('404'); }); In a single-page app, call postdeploy.track('404') from the not-found route instead, because that page event has already fired.
  5. After a few days, read the 404 goal's conversions by page. Each path is an address that does not exist. Read the same goal by referrer to see which sites send people to those addresses.

A page goal cannot catch these hits, because it matches one exact path and broken URLs are many different paths. The named event fires on every one of them.

A referrer names a host, never a page. The tracker strips referrer paths before it sends, so Analytics shows forum.example and never the thread with the bad link. You still have to search that site, or ask whoever runs that site. Query strings are removed too, except utm_source and utm_campaign, so two broken links that differ only after the ? show as one path. For broken links inside your own site, run a link checker against the deploy.

Leave the 404 page out of the Project's excluded paths. Excluded paths and everything under them are dropped before storage, so an exclusion that covers the error page hides the hits you want to see.

The product page for this is Analytics.

Start your 14-day free trial