Google Analytics is a powerful tool. It gives you a lot of valuable data like of where your visitors are find your website, which pages they are viewing and how long they are spending on your website. There is no report inside Google Analytics that gives you the HTTP status code of pages, but there is an easy way around this and you can easily identify 404 pages inside Google Analytics.
Requirements
The main requirement for this is obviously that you are using Google Analytics.
- Google Analytics is installed on your 404 error page template.
- You are not be redirecting 404 links to anywhere else (this is also bad for your SEO).
- You have a unique title for your error page (like “Sorry, page not found” or similar).
Identify 404 pages in Google Analytics
1. Inside Google Analytics, navigate to Behvaior > Site Content > All Pages.
2. Add a secondary dimension of “Page Title“
3. Add an advanced filter to include “Page Title” containing the title of your 404 error page.
4. Analyse your broken 404 pages!
That’s it! Simple, right? You now have a list of all hits from your users on pages that 404’ed.
If you don’t see any results, try to increase the date range as there may have been no 404 errors recently. Re-check that your filter is applied correctly (you can use RegEx if your page title is not a simple one). If you still don’t see any results, then congratulations, you website has no broken pages! Though, I would be very skeptical of this and purposely invoke a 404 error so I can confirm my tracking and filter is working.
What to do with broken pages?
If you see a lot of pageviews to particular broken pages, that means there are either broken links, either on your site (internal links) or somewhere external (inbound links). You should aim to identify and fix broken internal links. To take care of broken inbound links, you can setup redirects for those URLs to the right (or replacement) page. You should do this particularly for any page paths you find that have a lot of pageviews. However, you should not redirect all the 404 pages you find.
Some paths may be a genuine 404, like when a certain piece of content is deleted for whatever reason. Redirecting to a different page (even if it is somewhat related), is not recommended as that will not be what the user was looking for, and is also not recommended due to SEO. Such pages, let me them 404 and make sure you have a helpful 404 page that guides users around your site.
Some paths may be a typo, if a user tried typing the full page path, or someone may have copy-pasted incorrectly, etc… These too, you don’t need to bother fixing as such mistakes can and will continue to happen. You cannot setup hundreds of redirects for these. Once again, having a helpful 404 error page will help here.
You can also use this trick for any other kinds of errors, like a 500 server error to identify which pages crash frequently. Of course, it will require that your page title be different based on the error code