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.

Note: If you don’t want to set this up manually, you can just scroll down a bit and import this report from the Google Analytics solution gallery.

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.

Note: Again, if you don’t want to set this up manually, just scroll down and import this report from the Google Analytics solution gallery.

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:

32 Comments

  1. Alex Gogarty
    5. July 2018

    Hi Eoghan,

    Great article, clear and well-written! Thank you for sharing.

    I have a slightly different question. Our 404 page includes four internal links suggesting to the user where on our site to go next.

    I’d like to see which of those links gets the most clicks – I would go by Previous Page Path on those specific four pages, but that necessitates using the 404 URL and not the Page Title.

    Do you have any suggestions on how I could get this data/track the next pages most commonly visited after the 404?

    Thanks so much!

    Alex

    Reply
    • Eoghan Henn
      13. July 2018

      Hi Alex,

      Thank you very much, I’m glad you found the article useful.

      I suggest you use Google Tag Manager to track the clicks on those links as events in Google Analytics. If you need any help with this, just let me know. I’ll be happy to send you some instructions.

      Reply
  2. Anjali
    26. June 2018

    Hi Eoghan,

    Your report seems to be really helpful.

    But, when I am creating the same report in GA dashboard, it shows nothing. However, can see 404 urls in search console.

    Please check sample URL: –removed–

    I request you not to publish this comment with the mentioned URL. 🙂

    Thank you
    Anjali

    Reply
    • Eoghan Henn
      3. July 2018

      Hi Anjali,

      Your 404 page does not contain the Google Analytics tracking code, so it is not being tracked in GA currently. You should make sure your 404 pages are tracked in GA for the report to work. And even then, the report will only show URLs that have been accessed by users, so they won’t mirror what you see in the crawl error reports in GSC.

      As requested, I removed the sample URL from your comment.

      I hope this helps!

      Reply
  3. Smita Haldankar
    3. May 2018

    Hello Sir
    I face crawl errors because last month I changed the name 3 urls and 1 url removed.
    But now as search console detected as error for old url, I don’t know how to fix it.
    Please would you suggest me what should I do and fix the errors.
    Please mail your advice to me.
    As I cannot found it here.
    Thank you.

    Reply
    • Eoghan Henn
      14. May 2018

      Hello Smita,

      For the URLs you changed, you should set up 301 redirects from the old URLs to their new equivalents. Depending on what system you’re using, you’ll probably find a plugin to easily manage this.

      For the URL you removed, you can check if there is a fitting target (another URL with similar content) that you can redirect it to.

      I hope this helps!

      Reply
  4. Aldo
    25. April 2018

    I read on Google official blog that 404 errors — or even too many such pages won’t hurt our blog and its pages on Google result pages.

    But now I am having about 500 pages labelled 404 not found to which is hurt for my new post to get ranked.

    The reasons for this issue after migrating from Blogspot to WordPress, many of the post’s permalink from Blogspot changed when it’s converted to WordPress’s permalink.

    Reply
    • Eoghan Henn
      1. May 2018

      Hi Aldo,

      You’re right, 404 errors normally don’t hurt your rankings directly, but they’re still something you should avoid and take care fo for several reasons (see article and other comments).

      If your URLs change due to a system migration, you should set up 301 redirects from your old URLs to their new equivalents. Even if it’s been a long time since the migration, you can still set up these redirects.

      I hope this helps! Please let me know if you have any further questions.

      Reply
  5. David
    12. April 2018

    Thank you, have tested this code out and works great. Was thinking there maybe a better wy using GA’s AutoTrack Plugins however, your method gives good results.

    Reply
    • Eoghan Henn
      12. April 2018

      Hi David. I’m glad this worked out for you. And yes, there are probably lots of other (and better) ways to do this.

      Reply
  6. Sasa Rebic
    22. March 2018

    Hi Eoghan,
    great text, I have problem with client who have too much broken link. How fast fix this problem. He has 4000 page on site. I found 8 broken link on one page.
    Thx in advance

    Reply
    • Eoghan Henn
      4. April 2018

      Hi Sasa,

      I would recommend crawling the entire website with a tool like Screaming frog and exporting all links to URLs that return errors. As a quick fix, you can set up 301 redirects from the error URLs to equivalent working URLs, but this should only be a temporary solution. It is not desirable to keep internal links to redirect very long. In the next step, there’s really no way around checking all of the faulty links you’ve exported and fixing them step by step.

      I hope this helps! Please let me know if you have any further questions.

      Reply
    • Damian
      25. April 2018

      Hi Sasa,

      You can use Google Analytics as per Eoghan’s article or download a list of 404 errors from the Google Search Console (under Crawl Errors).

      Once you have this list you can use an automated URL mapping tool like https://getredirects.com (shameless plug) to match broken URLs to existing pages on your site and create 301 redirects.

      Hope this helps,
      Damian

      Reply
      • Eoghan Henn
        26. April 2018

        Hi Damian,

        Interesting tool. Keep up the good work and all the best!

        Reply
  7. Michael Julian
    21. March 2018

    Hello Eoghan,

    We just made some changes to our site structure and your article has been very helpful.

    One issue I seem to be having is the external link report. I have found known external links that are broken on sites but can ‘t seem to get anything to show up in the report.
    I imported your reports and the internal report works great but it seems I may need a different configuration to get the external report to work.
    Any thoughts?

    Thanks
    Michael

    Reply
    • Eoghan Henn
      4. April 2018

      Hi Michael,

      I’m happy to hear that my article has been helpful. Errors from external links will only show up in Google Analytics if users actually click on the links and land on your error page. Maybe the links you are referring to haven’t generated any traffic? You can test this by clicking on the links yourself and making sure that you’re actually being tracked (and not filtered out of the view because of an internal traffic filter) by checking the real-time report. Your own visits should then show up in the external link report after a couple of hours.

      If this doesn’t work, please let me know via e-mail, so we can have a look at it together to see what needs to be fixed.

      Reply
  8. Anup Nair
    12. March 2018

    The is exactly what I was looking for. There is so much in Google Analytics, that you need to know how to choose right elements to get the information you seek.

    Thanks a lot Eoghan Henn

    ps. wondering if I can use Custom Reports for Server Response time and Page Load Times (although I get the figures as in Site Behaviour, but something more detailed to track and fix)

    Reply
    • Eoghan Henn
      13. March 2018

      Hi Anup,

      I’m glad you found this useful.

      Sure, you can create custom reports with almost all metrics and dimensions that are available in Google Analytics. I recommend you play around with it a bit, in order to find something that fits your needs. What I really like about the “Flat Table” option ist that you can combine up to five dimensions! This gives us a lot of room for interesting reports.

      Reply
  9. Irvin
    27. February 2018

    Hello Eoghan,

    Thanks for this information. However, in my case it seems different, search console shows 404 error on page that i do not know exited. Like the URL’s below. It gives me headache.

    https://www.sample.com/%E5%A4%A7%E5%A5%96%E8%80%81%E8%99%8E%E6%9C%BA%E4%BF%A1%E8%AA%89%E5%A5%BD%E4%B8%8D%E5%A5%BD+Q82019309.com.com

    %E5%A4%A7%E5%A5%96%E8%80%81%E8%99%8E%E6%9C%BA%E6%89%8B%E6%9C%BA%E7%89%88+Q82019309.com.com/

    %E5%A4%A7%E5%A5%96%E5%A8%B1%E4%B9%90%E6%80%8E%E4%B9%88%E6%B3%A8%E5%86%8C+Q82019309.com.com/

    %E5%A4%A7%E5%A5%96%E5%A8%B1%E4%B9%90TTG%E8%80%81%E8%99%8E%E6%9C%BA%E6%B3%A8%E5%86%8C+Q82019309.com.com/

    404

    %E5%A4%A7%E5%A5%96%E6%8D%95%E9%B1%BC%E5%BC%80%E6%88%B7%E9%80%81%E9%92%B1+Q82019309.com.com/

    404

    %E5%A4%A7%E5%A5%96%E5%A8%B1%E4%B9%90%E5%AE%98%E7%BD%91%E7%99%BB%E5%BD%95%E5%85%A5%E5%8F%A3+Q82019309.com.com/

    404

    %E5%A4%A7%E5%A5%96%E6%B3%A8%E5%86%8C%E5%B0%B1%E9%80%81%E9%92%B1+Q82019309.com.com/

    404

    %E5%A4%A7%E5%A5%96%E6%8D%95%E9%B1%BC%E8%B5%8C%E5%8D%9A%E7%BD%91%E7%AB%99+Q82019309.com.com/

    404

    Reply
    • Eoghan Henn
      7. March 2018

      Hi Irvin,

      These look like percent encoded Chinese URLs. If you let me know what website it is, I can have a closer look. Often, but not always, there’s a simple explanation for why Google’s bot discovers certain URLs.

      Reply
    • Nancy
      25. April 2018

      Need solution for the same too, GWT showing around 1K results with such queries. What solution do you recommend?

      Reply
      • Eoghan Henn
        1. May 2018

        Hi Nancy,

        If you send me an example, I’ll be happy to have a look.

        Reply
  10. berbagi73
    27. January 2018

    Hi Eoghan,
    thank’s for quick response my comment. I try your suggestion.

    Reply
  11. berbagi73
    27. January 2018

    Hi, Eoghn Henn
    I have crawl error on webmaster. When I opened it”s not my page. Ex : myblog/2017/01/content-wrapper
    I removed it, with remove url from webmaster. After few month the error page was comming again on report.
    So I make redirect option from blogger dashboard to another page I haved.
    my question is, do I need remove again that issue or ignore that, because I already redirect to another page.
    sorry if my language not good.

    Reply
    • Eoghan Henn
      27. January 2018

      Hi Berbagi,

      Thank you very much for your comment. Please don’t worry about your language. I understood everything you wrote perfectly well.

      You did the right thing redirecting the URL. You can now mark it as fixed in your error reports and it should not show up again. There is no need to remove the URL via the “remove URL” feature if there is a redirect in place. One thing that you can do to speed up the process of removing the URL from the index is the following: Go to Crawl > Fetch as Google (in Google Search Console) and fetch the old URL (myblog/2017/01/content-wrapper, in your example). The status should show as “Redirected” and you can click on “Request indexing” next to it (see screenshot).

      Fetch URl with Google Search Console, status redirected, request indexing

      By doing this, tho old URL should disappear form the index very quickly.

      I hope this helps! Please let me know if you have any further questions.

      Reply
  12. Ben
    19. January 2018

    Still amazes me that this isn’t a default report in GA?

    Reply
  13. Josh
    10. January 2018

    Thank you. Your custom 404 report was just what I needed.

    Reply
    • Eoghan Henn
      15. January 2018

      Thanks, Josh! I’m glad you found it helpful.

      Reply
  14. Joe
    14. December 2017

    Hi Harris,

    Great article! I notice the 404 errors reported are in root-relative rather than absolute. How do I get the report to show the absolute URLs?

    Thanks you,
    Joe

    Reply
    • Eoghan Henn
      21. December 2017

      Hi Joe,

      The reports in GSC only show URL paths, but when you download them, you get the full URLs.

      I hope this helps!

      Reply
  15. Harris
    28. November 2017

    Fantastic post! I only wish you had told me about the solutions gallery link before I did it manually 🙂

    Reply
    • Eoghan Henn
      1. December 2017

      Hi Harris! I’m sorry, you’re right. I added a note above the instructions so that this doesn’t happen to anyone else 🙂

      Reply

Leave a Reply