There have been multiple blog posts written over the years on how to use Google Analytics to identify and fix 404 Error Pages.
I have even written one myself and it’s a common slide in many of my talks. But with the newest features that are available within Google Analytics, these blog posts are due an update.
Custom Variables vs Events
The first question is whether to capture details of the 404 Error Page within page level customisations or as an event.
My approach is to capture more information about the page using page level customisation. Since viewing a 404 Error Page is not an event, it should not be treated as one.
Google Analytics tracking
Step one in the GA tracking for Error Pages is to rename the page name to /error-page/404-error. This means all views of this page are grouped together, making them easier to identify and analysis becomes significantly easier.
There are two key pieces of information to capture on each 404 Error Page. The first is the URL of the page and the second is the referrer to the page.
Both are available as default Variables within GTM (Google Tag Manager) and so no developer support is required to capture them. The L3 Analytics approach is to capture the Page URL as a Content Grouping and the Referrer as either a Content Grouping or a Hit scoped Custom Dimension.
Previously I would have stopped at that tracking, but an Error Page view should now also be captured as a Custom Metric. It will provide an easy way to see the total number of Error Page views for the website or broken down by any session/user dimension.
Google Analytics configuration
Previously, we always recommended creating a Goal for View Error Page. It is useful to know if visitors are seeing 404 Error Pages and if this metric ever exceeds a certain value (e.g. 2%) for this to trigger an immediate action.
This should be set up as a Custom Alert within Google Analytics to notify you when visitors are experiencing an excessive number of 404 Error Pages.
To investigate the cause of 404 Error Pages, a Custom Report is required. It’s fairly simple, the report is filtered to only include data from 404 Error Pages and the dimensions are the Page URL and the Referrer.
The metrics in this example are Pageviews and Unique Pageviews (basically error counts) although you can now use the Custom Metric of Error Page Views.
There are two tabs within this Custom Report with the dimensions simply reversed in the second tab. When the report is run, it displays URLs which trigger the 404 Error Page, allowing you to click through to see the referrer to this page.
Switching to the second tab flips these two dimensions, displaying the referrers that trigger 404 Errors and allowing you to click through to view the URLs of the error pages. While this doesn’t solve everything, it allows you to identify the source of 404 Error Pages and where they are sending traffic to in error.
You could search the page source for these URLs or it might be obvious from their structure why there is a problem.
There was one occasion on which we really had to dig deep into the data to identify the cause of a 404 Error Page; have a look at our real-life example here.