How to Track and Fix 404 Errors with Website Analytics
Every time a visitor hits a 404 page on your site, you lose them. They arrived with intent — from a search result, a link on another site, or a bookmark — and instead of finding useful content, they hit a dead end. Most leave immediately and never come back.
The frustrating part is that 404 errors are almost entirely fixable. You just need to know where they are. Website analytics gives you exactly that data — a live record of every broken URL being hit on your site right now.
Why 404 Errors Hurt More Than You Think
A single 404 hitting a handful of visitors per month might not matter much. But a broken URL that was once linked from a popular article, a Google result, or a social share can silently drain traffic for years. Consider the full damage:
- Lost organic traffic: If Google has indexed a URL that now returns 404, that ranking is gone until the URL is restored or a redirect is in place. Older sites with frequent URL changes accumulate dozens of these phantom rankings.
- Broken backlinks: Every inbound link pointing to a dead URL is a wasted backlink — you're getting no SEO value from it. A 301 redirect to a relevant page recovers most of that value.
- Lost ad traffic: If you're running paid ads that link to a page you've since deleted or moved, every click is money wasted on a bounce.
- Damaged trust: Visitors who encounter a 404 on a site they were about to trust with their email or payment often walk away permanently.
How statpx Detects 404 Errors
statpx automatically detects 404 pages using a simple pattern: the tracking snippet records the page path of every pageview, and you can filter the Visitors tab to show sessions that hit your 404 page URL (typically /404, /404.php, /not-found, or whatever your server serves for missing pages).
To make this even easier, add one line to your 404 page template so that every 404 hit fires a named custom event alongside the pageview:
This fires an event with the name 404_hit and uses the requested path as the category. In your Events tab, you'll see a clean list of every URL that has returned 404, sorted by frequency, along with the referrer for each hit — so you know whether the broken link is coming from Google, another website, or your own internal links.
Finding and Fixing 404s: Step by Step
- Filter your Visitors tab by your 404 page path. In statpx, go to Visitors → search for your 404 path in the path filter. You'll see every session that hit the 404 page along with the referrer (where they came from) and the specific URL they were trying to reach.
- Check the referrer for each broken URL. A 404 coming from Google means a de-indexed page that still drives clicks. A 404 from another website is a backlink you can reclaim. A 404 with a direct/no-referrer source is usually a broken internal link or outdated bookmark.
- Group by frequency and prioritize. Fix the URLs receiving the most hits first. A URL hit 200 times per month is worth a 301 redirect immediately; one hit twice ever is lower priority.
- Add 301 redirects for broken URLs. In Apache, add lines to your
.htaccess. In nginx, update your server block. For WordPress, use a redirect plugin. Point broken URLs to the closest equivalent live page — not always your homepage. - Verify the fix. After adding redirects, confirm the old URL now returns a 301 (not a 302 or another 404) using a tool like
curl -I https://yoursite.com/old-url.
Common Sources of 404 Errors
CMS URL structure changes
Switching from /blog/post-title to /articles/post-title without redirects breaks every inbound link overnight. This is one of the most common — and most damaging — sources of mass 404s on established sites. Before any URL structure migration, audit your inbound links and have redirect rules ready to deploy immediately.
Deleted or moved pages
Removing a product, service, or blog post without redirecting its URL leaves a 404 wherever it was linked. Check the referrer data in your analytics to see which deleted pages still receive traffic and where that traffic is coming from.
Typos in internal links
A mistyped href in your navigation or body copy creates a dead link that your own visitors will hit. Regular checks of your entry and exit pages can surface pages with unusually high exit rates, which sometimes signal a broken next-step link.
Case sensitivity
On Linux servers, /Blog/Post-Title and /blog/post-title are different URLs. Links shared on case-insensitive systems (like Windows) might use mixed case that breaks on your server.
Find broken URLs before they cost you rankings — free with statpx
statpx records every page path hit on your site, including 404s. Add the custom event snippet to your 404 template and get a sorted list of broken URLs in minutes.
Start tracking free →The Bottom Line
404 errors are a maintenance problem that compounds quietly over time. Fixing them is one of the highest return-on-effort tasks in site management: a few hours of work to add redirects can recover years of accumulated backlink equity and stop the steady drain of organic traffic. Your analytics already has the data you need — start with the 10 most-hit broken URLs and work down the list. Most sites can eliminate 80% of their 404 traffic in a single afternoon of cleanup.