Handling 404’s Gracefully

You can spend countless hours working on your website, tuning and tweaking as much as you can. You can link check and scan and editorialize every page. But you will still get 404’s.

It may be from typos in links from other sites. It may be from retiring or renaming a page. It may simply be a malformed crawler. The key point is that you need accept that they will happen and have a plan for it.

There are three main aspects to consider:

  1. Redirect when appropriate
  2. Explain where necessary
  3. Track always

Redirect When Appropriate

This is your first “line of defense” because it gives you control over the situation for specific pages. If you’re updating your site to rearrange content then it’s a good idea to put redirects in place so that the old links still work. Maybe you can redirect to the new content, maybe you just redirect to a page explaining the redesign.

If the move is a permanent one, please make sure that you use a 301 redirect.

Explain Where Necessary

Every site should have a 404 page. The page should be styled like the rest of your site and include some text about the page not being found – possibly with links to other helpful pages on the site.

Do not simply leave the webserver’s default 404 page in place.

Track Always

You should already have an analytics solution in place on your site and it can be used to track 404’s just like “regular” site traffic.

There are 2 main ways to track 404 traffic – via title tag and via custom page request

With Title Tag

If your 404 page always has a specific phrase in the title tag, you can filter your analytics report by title tag. In Google Analytics, simply navigate to Behavior -> Site Content -> All Pages, select Page Title as the Primary Dimension, and type in your phrase in the search box.

google-analytics-find-404-by-title@2x
Select the Page Title as they Primary Dimension and your 404 page tile phrase as the search terms.

This will show you all instances of your 404 page in the analytics and you can drill down to see the URLs that triggered it.

With a Custom Page Request

If you have the ability to adjust your analytics JS on your 404 page you can actually use a different “page” to track it in your analytics.

This will show you both the page that someone was trying to reach and the referrer where they came from (if available).

Closing

Now that you are tracking 404 pages in analytics, you should either extend your existing analytics review process to include checking the 404’s or add a new task to your calendar to review them and address as appropriate.