Monitoring and fixing 404 errors with Google Analytics

Last updated on May 18, 2017

In this article, I explain how you can use two very simple custom reports in Google Analytics to monitor 404 errors on your website. If your 404 error page is set up correctly, Google Analytics already automatically tracks all 404 errors encountered by users. With the two custom reports I present in this article, you can easily find these errors and fix them.

First of all, let’s have a look at how your 404 page should be set up (not just for tracking purposes, but also for SEO reasons):

  • The 404 page should always load on the false URL that has been called, and should NOT have its own URL (like, e.g., /404/).
  • When a URL that does not exist on your website is called, this URL should give back a 404 HTTP status code, and not a 200 (OK) status code or a 301 redirect to an error page with a different URL.
  • Only for tracking purposes: Make sure the page title (in the title tag) of your error page contains “404”, “page not found”, or another expression you can use to identify the page in Google Analytics.

If you want to see an example of a 404 page that is set up exactly like this, just go to https://www.rebelytics.com/this-url-doesnt-exist. The 404 page on this website is pretty boring and not very helpful, but at least from a technical perspective it’s fine.

So, if your 404 page is already working like this, you can just move on and create the two custom reports I am presenting next. If not… well, fix it and come back. I’ll wait for you right here ūüôā

Custom report for finding and fixing 404 errors caused by internal links

The first very handy custom report I would like to show you today helps you find internal links that cause 404 errors on your website. Internal links are links that point from one page on your website to another page on your website. You have full control over these links, so you can fix errors as soon as you find them. Internal links to 404 errors are bad for the user experience of your website and they can also harm your SEO performance.

Here’s how to set up the report (also see the screenshot below for better orientation):

  • Go to Customization > Custom Reports in Google Analytics and click on +New Custom Report.
  • Select the report type Flat table.
  • Select the dimensions Page, Previous Page Type and Page Title.
  • Select the metric Unique Pageviews.
  • Add a filter that excludes the value (entrance) for the dimension Previous Page Path. This filter makes sure that only 404 errors that were preceded by a page view on your own website (and thus caused by an internal link) show in the report.
  • Add a Regex filter for the page title that contains the expression that helps you identify your 404 error page (“404” in the example below, but it could also be “page not found” or something else, depending on the title tag of your 404 error page).

Now, if you save the report and open it, you will see the following columns:

  • Page: URL that caused a URL error.
  • Previous Page Path: Page that links to the false URL (in most cases).
  • Page title: Title of your 404 page.
  • Unique Pageviews: Number of sessions this error happened in.

And here’s what you can do to fix the errors:

  • Set up a 301 redirect for each URL in the first column to a matching target. This redirect makes sure that every user and search engine bot that tries to access the faulty URL from now on is redirected to a page that works.
  • Go to each URL in the second column, check if there is really a link to the false URL in the first column on it (sometimes there might not be one, because the URL can end up in this report for other reasons, for example if a user manually types in a false URL while he or she is already on a different page on your website), and fix the link. This is necessary in addition to setting up the redirect for the faulty URL, because internal links to 301 redirects are also a bad signal for search engines and have a negative impact on user experience, because they slow down the loading of the next page.

If you don’t want to go through the hassle of setting up this custom report yourself, you can import it¬†directly from the Google Analytics Solutions Gallery:

404 errors from internal links by Eoghan Henn

Now that you are taking care of your 404 errors caused by internal links, let’s have a look at 404 errors that are caused by links from other websites to yours.

Custom report for finding and fixing 404 errors caused by external links

The second custom report I would like to share with you for the purpose of monitoring 404 errors on your website is a close variant of the first one. The difference is that this second report shows you 404 errors caused by external links. External links, in this case, are links that point from other websites to pages on your website. You normally don’t have direct control over those links, so you can’t just fix them when you find them.

Here’s how to set up this report (again, you’ll find a screenshot below for better orientation):

  • Go to Customization > Custom Reports in Google Analytics and click on +New Custom Report.
  • Select the report type Flat table.
  • Select the dimensions Page, Full Referrer and Page Title.
  • Select the metric Unique Pageviews.
  • Add a filter that includes the value (entrance) for the dimension Previous Page Path. This filter makes sure that only 404 errors that were not preceded by a page view on your own website (and instead caused by an external link) show in the report.
  • Add a Regex filter for the page title that contains the expression that helps you identify your 404 error page (“404” in the example below, but it could also be “page not found” or something else, depending on the title tag of your 404 error page).

Now, if you save the report and open it, you will see the following columns:

  • Page: URL that caused a URL error.
  • Full referrer: Page on another website that links to the false URL. Please note: In lots of cases this will not help you actually find the faulty link, as it includes referrers like “Google” for clicks from search results and lots referrers are not passed correctly. Focus on referrers that actually look like URLs of pages that are linking to your content.
  • Page title: Title of your 404 page.
  • Unique Pageviews: Number of sessions this error happened in.

And here’s what you can do to fix the errors:

  • Set up a 301 redirect for each URL in the first column to a matching target. This redirect is very important for users or search engine robots that follow the link from the other website to yours. You don’t want them to end up on an error page. Make sure the content on the redirect target is as similar as possible to the content that was originally linked to.
  • Check the second column for false links that you can actually identify. In some cases¬†it might make sense to reach out to webmasters that link to URLs on your website that don’t exist to ask for a link update.

You can also import this report directly from the Google Analytics Solutions Gallery:

404 errors from external links by Eoghan Henn

Any questions or comments?

If you have any questions about this article, please don’t hesitate to leave a comment. I normally manage to reply to all comments on this website within a couple of days.

Also, I would be very happy if you shared this article:

Leave a Reply