Skip to content

Find broken pages (404) with your analytics

Updated October 19, 2026

Broken links cost visitors quietly: someone follows an old link, lands on "page not found" and leaves. Your server logs know about it; your analytics usually does not, because a 404 page looks like any other page.

Send an event from the 404 page

Add one line to your "not found" template, so every visit to it sends an event with the address that failed:

<script>
  window.addEventListener('load', function () {
    window.statsdot && window.statsdot.track('404', location.pathname);
  });
</script>

Where to put it:

  • WordPress: the theme's 404.php (in a child theme), before get_footer().
  • Laravel: resources/views/errors/404.blade.php.
  • Next.js: app/not-found.tsx or pages/404.tsx, with the call in an effect.
  • Static sites: the 404.html your host serves.

Read it

In the Events panel, click 404 to see its labels: the broken addresses, most visited first. Filter by it to see where those visitors came from. A referrer points to a site with a bad link; search points to an old page Google still lists; direct often means a typo or an old bookmark.

Fix in this order

  1. Addresses with the most visitors.
  2. Addresses reached from other websites: ask them to fix the link, or add a redirect.
  3. Addresses reached from search: redirect them to the closest live page.

Create a goal for the event 404 and the dashboard shows how many visitors hit a broken page each month, so you can see the list shrink.