About cookies on this site

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. Learn more

Cookie settings

About cookies on this site

Cookies used on the site are categorized and below you can read about each category and allow or deny some or all of them. Learn more

Necessary

Some cookies are required to provide core functionality. The website won't function properly without these cookies and they are enabled by default and cannot be disabled.

Preferences

Preference cookies enables the web site to remember information to customize how the web site looks or behaves for each user. This may include storing selected currency, region, language or color theme.

Analytical cookies

Analytical cookies help us improve our website by collecting and reporting information on its usage.

Marketing cookies

Marketing cookies are used to track visitors across websites to allow publishers to display relevant and engaging advertisements. By enabling marketing cookies, you grant permission for personalized advertising across various platforms.

  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

March 30, 2025

How to Track and View 404 Errors with Google Analytics 4

Updated: March 30th, 2025

If someone on your website lands on a page that does not exist, that someone gets a 404 error. As a website owner, you don’t want your visitors to appear in a dead end. It hurts your brand, your conversions, and in some cases, your search engine optimization efforts. But that shouldn’t be a problem anymore, because in this blog post I’ll show you how to track 404 errors with Google Analytics 4.

If one method (explained in this article) does not work, I will show you a workaround that also includes Google Tag Manager.

Subscribe and Get the Ebook - working with reports in ga4

Table of contents

– Here’s what you will learn in this article –

  • The Premise
  • For the giggles
  • What Should You Do?
  • How Can You Track 404 Errors?
  • Track 404 Errors With Google Analytics 4 Engagement Reports
  • Track 404 errors with Google Analytics 4 and Google Tag Manager
    • Data Layer
    • A trigger
    • Create a Google Analytics 4 event tag
    • Let’s test
    • Build a report
  • OK, Now What?
  • Conclusion

 

The Premise

404 is an error message displayed by a browser indicating that an Internet address cannot be found.

Why is it bad? Mainly, it might hurt your conversions. Imagine that a person is looking for particular information, and you have that topic covered on your website. But when he/she clicks the link – no luck.

In most cases, that might result in a bounce or, even worse – the visitor might jump over to your competitor’s website and (possibly) make a purchase there.

 

For the giggles

In fact, did not plan to post this example at all, but it’s too hilarious.

Anyway, in 2017, I was looking for some blog post/guide to back up my arguments about why 404 errors are important to monitor and why they might hurt your business. So I did a quick search and stumbled upon the siteimprove.com blog post “What Broken Links Cost Your Business” in Google search.

Google search - 404 hurt conversions

Guess what? After I clicked the link, I got a 404 error. Oh, the irony! What do broken links cost your business? I don’t know… a bounce, I guess.

siteimprove 404

A simple 301 redirect could have solved this issue.

 

What Should You Do?

There are two steps that need to be addressed:

  1. You need to monitor 404 errors (that’s my main focus in this blog post).
  2. You need to fix those broken links by redirecting people to a new destination URL (I’ll cover some general tactics and tools without diving deeper into details).

 

How Can You Track 404 Errors?

In this blog post, I will cover two options:

  1. Track 404 errors with Google Analytics 4 engagement reports. An option that does not require additional development. I’ll explain it in a further chapter of this blog post.
  2. Track 404 errors with Google Analytics 4 events via Google Tag Manager. You will also learn this option here.

 

Track 404 Errors With Google Analytics 4 Engagement Reports

Is there a 404 page on your website? You can quickly check that by adding some nonsense in the URL. For example, https://www.example.com/post/nonsense.

If you see a “Page not found” message (or another warning on a screen), that’s a good start. Next, check the title of that 404 page. Mine is Page not found – Analytics Mania.

Page not found tooltip

If your 404 page’s title lets you distinguish that this is not just some regular page (but it says something about the page being not found), then this method will work for you. Continue reading.

If the title of your “Page not found” page is too generic (or maybe it’s just the same as your homepage), then the method I will show to you will not work. Jump to another chapter of this blog post where I explain a workaround with Google Tag Manager.

Anyway, let’s go back to the main topic of this chapter. Log in to your Google Analytics 4 property and go to Reports > Engagement > Pages.

Then make sure that the primary dimension (selected in the report) contains “Page title”.

In the search field (above the table), enter the title (or a part of it) of the 404 page. In my case, the full title was “Page not found – Analytics Mania”, so it was enough to enter just “Page not found”. Then hit “ENTER” on your keyboard.

Ideally, you should see one row in the report. That is your “Page not found” page where people land once they visit some broken link.

In that table, you will also see metrics such as Views (the number of times the page was loaded), Sessions, etc. But this is not helpful yet. We don’t know what where the URLs of those 404 errors.

To see that, click the plus icon in the report (to add the secondary dimension).

Then select the Page path dimension (available in the page/screen section). The final report will look like this.

To see the full Page Path (which is a part of the URL), hover your mouse on it (in the report).

And that’s it! Now you know how to view the Page not found errors in Google Analytics 4 without any custom coding or configuration in Google Tag Manager.

However, on some websites, page titles of 404 errors are not descriptive, and this method does not work. That’s where we could use Google Tag Manager.

Subscribe and Get the Ebook - working with reports in ga4

Track 404 errors with Google Analytics 4 and Google Tag Manager

Another way to approach this issue is to fire a Google Analytics 4 event when a visitor encounters a 404 error. In this chapter, we will have to cooperate a bit with developers. There are more advanced options where you could scrape the site (I show some examples in this course), but working with a developer is the most robust option.

 

Data Layer

When a visitor gets a 404 error, ask a developer to push that event to the Data Layer. We will later use that in your Google Tag Manager’s setup.

A sample code could look like this:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  'event' : 'page not found'
});

When a developer implements this code, open Google Tag Manager’s preview mode by clicking the Preview button in the GTM interface, then enter the URL of any 404 page, and click Connect.

When the preview mode fully loads, keep looking for the “page not found” event on the left side of the preview mode.

If you see the event, that’s good. If you don’t, then the developer did something wrong. He/she should double-check his/her code.

 

A trigger

Once the “page not found” event is in the data layer, it’s time to create a custom event trigger in Google Tag Manager. Basically, we will tell GTM to send an event to GA4 if there is a “page not found” in the data layer.

Go to Triggers > New > Custom Event and create a trigger with the following configuration:

Save it.

 

Create a Google Analytics 4 event tag

In this tutorial, I presume that you already have at least a very basic understanding of how to install Google Analytics 4 on a website. If not, then read this tutorial.

At this point, you should already have a Google Analytics 4 configuration tag in your Google Tag Manager container. We will use it soon in the GA4 event tag.

In Google Tag Manager, go to Tags > New > Google Analytics > GA4 event.

Then, enter a measurement ID (1) and a name for this event (that clearly describes it), for example, page_not_found (2). Don’t send “error” though, because this name is reserved by GA4.

In the Triggering section of the tag, click anywhere and then select the Custom event trigger you previously created.

We did not add any additional parameters/settings in this tag because the GA4 event automatically tracks the Page URL where the error occurred, and that’s pretty much all we need.

 

Let’s test

Once you have created the custom event trigger and a GA4 event tag, click the Preview button in the top right corner of the GTM interface.

Enter the URL of the 404 page and click Connect. Then check if the page not found event appeared on the left side of the GTM preview mode. Click it and check if the GA4 event tag fired.

If the tag fired, go to Google Analytics 4 > Admin > DebugView and check if you see the event there.

If the DebugView is not working, check this article.

If everything works fine, publish your changes in Google Tag Manager by clicking the Submit button in the top right corner.

 

Build a report

If you just implemented and published 404 error tracking in Google Analytics 4, you will have to wait for up to 48 hours to see the data.

Once that time has passed, go to Google Analytics 4 > Explorations > Blank.

Then click a Plus in the “Dimensions” section and select the following dimensions:

  • Event name
  • Page Path and screen name

In the Metrics section, add the Event Count metric.

Then double-click those two dimensions and one metric (to add them to the report).

Finally, in the Filters section, add the following filter: event name exactly matches page_not_found. If the name of your event is different, then enter that one.

Once you have added dimensions, a metric, and a filter, a report will look like this (obviously, the values will be different).

 

OK, Now What?

Once you’ve started tracking 404 errors with Google Analytics (or without), you can now learn more about how visitors interact with the website. Find out which pages are actually dead ends.

Usually, 404 errors are “born” when page URLs change, e.g., you edited a web address in order to add relevant keywords for SEO. If that page was already indexed by Google, new visitors from search results would be redirected to the old address of a non-existing page.

So whenever you change the URL, ALWAYS create a 301 redirect (a.k.a. moved permanently) from the old URL to a new one. If you’re using WordPress Plugin Redirection, you can easily do that right from your WP admin panel.

Also, this WP plugin automatically tracks 404 errors, which you can turn into 301 redirects immediately.

redirection wp plugin

Why is a 301 redirect so important? Because Google honors this setting, it understands that resource X is not available anymore under the old URL and has been moved to another web address. This way, the accumulated reputation is transferred from the old address to the new one.

Want to see what the URL of the previous page was that led the visitor to the current 404 page?Watch this tutorial (there is a section where I teach how to work with a referrer).

 

Track 404 errors with Google Analytics 4: Final words

In this blog post, I described two ways to track 404 errors with Google Analytics 4. The first option does not require any development – you can achieve the result using standard reports. The second one is to utilize Google Tag Manager and send 404 errors as events to Google Analytics 4.

 

Julius Fedorovicius
In Google Analytics Tips Google Tag Manager Tips
14 COMMENTS
Wassim
  • Nov 23 2017
  • Reply

Hi Julius,

Thanks for the answer. I do have question though about your answer; How is a custom segment more flexible if an entire View can show you the same thing and also allow you to work with historic data? I am trying to make a decision on this before I go ahead.

Thank you

    Julius Fed
    • Nov 25 2017
    • Reply

    The entire view is limited only to certain pages. What happens if you make a mistake in configuration? The data will be missing or will be incorrect. Meanwhile, the segment allows you to filter/work with data which is already collected and you can slice it whatever you want. With segments, you can see how people who get a 404 convert, act on other pages, etc.

Mike
  • Jul 22 2019
  • Reply

Can you also track 404 errors from outbound links to external sites?

    Julius Fedorovicius
    • Jul 22 2019
    • Reply

    Not with GTM (because you cannot place your GTM code there).

mohammad
  • Sep 8 2020
  • Reply

Hi Julius,

A question is getting on my nerve.

As we know when the user sees page 404, it reports to us, so what is the difference between the two reports?
Why track 404 error with GTM "is more recommended" than GA?

    Julius Fedorovicius
    • Sep 8 2020
    • Reply

    What if the page title does not imply that there is 404 error?

      mohammad
      • Sep 8 2020
      • Reply

      So it doesnt track in GTM.
      The article said that Page title is considered as Variable. So if not so "page title does not imply that" GTM does not report that too. unless we set this tag with anothor variable.
      is it correct?

        Julius Fedorovicius
        • Sep 8 2020
        • Reply

        None of those options is superior. They are alternatives. If you want to see 404 errors as events, you will have to use GTM. If you are fine with pageview default data, then don't implement additional tracking via GTM.

        If the page title does not imply, you could ask a developer to push the 404 error data to the Data Layer and use that together with GTM.

        Many ways to tackle the situation.

          mohammad
          • Sep 8 2020

          yeah, its true. tnx for time.

David Mac
  • Jan 12 2022
  • Reply

Can you say how you would adapt this approach for an SPA built by Gatsby? Missing paths don't generate a fetch to the back end.

    Julius Fedorovicius
    • Jan 26 2022
    • Reply

    Ask a developer to push the 404 error to the data layer and then take that data from there.

Sharon
  • Nov 22 2022
  • Reply

New question here... I have followed these instructions however it isfiring on all pages, not just the page not found ones.

I have a suspect page that is turning up a significant amount of page not found errors and it is not my page. I just need to find out where it is referring from.

    Julius Fedorovicius
    • Nov 22 2022
    • Reply

    Then you need to make your trigger more precise so that it would fire only on the 404 page

Daz
  • Aug 14 2023
  • Reply

Nice work Julius. Adding this report to the Engagement collection allows me to keep an eye on 404's at a glance. Thanks again.

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Google Tag Manager Server-Side Tagging with Stape
  • How to Preserve Ad Click IDs with Server-side Tagging
  • LinkedIn Conversions API with Google Tag Manager. The Guide.
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings