Find broken links using Google Analytics 404 report

Updated on February 3, 2025.

If you want to find 404 pages in Google Analytics, you’ve come to the right place. In this article I will show you three methods how to track 404 errors in Google Analytics and build a simple custom 404 report.

#1. Track 404 errors in Google Analytics using Google Tag Manager

This method requires Google Tag Manager to be installed on your website (read here how to install GTM) and uses a custom event, which is a bit advanced and requires additional effort, but I like how explicit it is. Additionally, if you use multiple analytics platforms, you can achieve consistent results by reusing the event across all platforms you are using.

Add the code snippet to the 404 page template

In order to utilize the Google Tag Manager custom event for 404 error reporting, you will need to add the following code snippet to your website’s 404 page template:

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'error_404'
  });
</script>

If you are using WordPress, that should be fairly simple. Go to Theme File Editor, find in the right sidebar 404 Template, and put the code there:

Create a custom event trigger

Next, you’ll need to go to the Google Tag Manager trigger section and create a new trigger to fire every time the error_404 event is pushed to the dataLayer:

Create a Google Analytics event tag

Finally, we need to set up a GA4 event tag to send the event to Google Analytics:

You can see that in the screenshot above I’m using the {{Event}} variable, which means that it will send the dataLayer event, which is error_404. If you want, you can use any other event name that makes sense to you.

Debug the changes

Now, if we go to the preview mode and type in any non-existing URL within our website, we should get the error_404 event, which will fire the newly created tag and send data to Google Analytics:

Create a custom 404 report in Google Analytics

In Google Analytics, go to Explore in the left menu and create a new report and add four fields:

  • Dimensions → Event name.
  • Dimensions → Page path and screen name: shows the URL path of the page where the 404 error occurred (basically, the broken link).
  • Dimensions → Page referrer: shows the URL from which a user arrived at the 404 page (we can identify on which page the broken link is located)
  • Metrics → Sessions


Map each field and create a filter so that the report shows only the error_404 events that we are sending via Google Tag Manager. If you use a different name in your GA4 event tag, adjust the filter accordingly.

And we are done! Here is what our custom 404 report should look like in Google Analytics:

The event name column is actually redundant since we have a filter to show only a single event name. For demonstration purposes, I left this field.

#2. Track 404 errors in Google Analytics using the create event feature

This method doesn’t involve using Google Tag Manager or adding any code. We will use the built-in capabilities of Google Analytics, which also allow us to fire custom events. But since we are not adding any code, we still need something to base our trigger on. Fortunately, most of the platforms use the same page title for a 404 page.

Find your 404 page title

We can get it by visiting any nonexistent URL on a website:

In the example above, it is Page not found – Demo. Knowing the title, we can create a custom event from another event.

Create an event in Google Analytics

In Google Analytics, go to Admin → Data display → Events, and click Create event:

In the event configuration, we set our custom event name (I use error_404_ga, but feel free to choose any that works for you) and add two conditions:

  • event_name equals page_view
  • page_title starts with Page not found (replace it with your 404 page title)

Now Google Analytics will fire the error_404_ga4 event each time the specified conditions are met.

If you don’t add the event name = page_view condition and rely only on the page_title condition, you will end up getting multiple custom 404 events because any event on the 404 page will trigger our custom event: first_visitsession_startuser_engagementscroll, etc.

Build a report

Create a custom report using the same fields from the previous section, and you will see something like this:

In the screenshot above I have two 404 events:

  1. The first is coming from Google Tag Manager, which was set up using the previous section.
  2. The second is coming from Google Analytics.

Clearly, it’s redundant; you don’t need to create a Google Analytics event if you’re using the Tag Manager option and vice versa. Stick with either one of those.

I personally don’t use custom GA4 events at all. It brings extra confusion when custom events are handled by both GTM and GA4. I find it more streamlined to have everything in GTM, especially when working with multiple analytics platforms such as Piwik Analytics or Microsoft Clarity. By doing so, you don’t have to configure meaningful events in each; just create a tag in GTM, and it’s done.

#3. Find 404 pages in Google Analytics using the page title

Okay, so this is actually the method that won’t require any changes to your tracking at all. What makes it great is that you can get a 404 report in your Google Analytics from the already collected data.

Since we have established our 404 page title, which in our case starts with Page not found, we can use it as a condition and skip custom event configuration.

Create a 404 report with the page title filter

In Google Analytics, go to Explore in the left menu and create a new report and add four fields:

  • Dimensions → Page path and screen name: shows the URL path of the page where the 404 error occurred (basically, the broken link).
  • Dimensions → Page referrer: shows the URL from which a user arrived at the 404 page (we can identify on which page the broken link is located)
  • Dimensions → Page title
  • Metrics → Sessions

You might wonder why the page referrer is empty. It is blank because the sessions’s source / medium is direct / (none), meaning a visitor typed in the URL directly.

The report configuration is pretty much the same as in the Google Tag Manager section, but I’ve added the Page title dimension. We use it for filtering purposes to show only page titles that start with Page not found. Since we are reporting sessions, we don’t actually need another filter to show only the page_view events.

This solution is not sophisticated, but it is hassle-free and. More importantly, it does not require any configuration at all. You can retrieve the 404 pages from previous periods, which is not accessible with the 404 custom event tracking.

Next steps

So you’ve identified the broken links using a the 404 report in Google Analytics. What text?

1. Fix broken links

If you followed this guide precisely, you should have the page referrer column in your report. It will be populated with the URLs containing your broken links, which result in 404 errors. Simply visit the page, search for those links, and make sure to replace them with the working ones.

2. Set up redirects

If the referrer is an external website, you won’t see the exact page — only the domain. And most likely you won’t be able to change the URL. What you can do, however, is configure a redirection to another relevant page on your website. This can be done in the .htaccess file:

Redirect 301 /google-ads-management /new-page

If you are using WordPress you can use the Redirection plugin. But since most SEO plugins have the redirection feature, you won’t have to deal with any custom code:

3. Check your 404 report in GA

Unfortunately, there is no alerting system in Google Analytics 4, so you will have to manually visit the 404 report once in a while to ensure you are not losing traffic due to 404 errors.

Hi! I’m Roman, a Google Ads freelancer. This is my website where I share all kinds of things I find interesting related to Google Ads, Google Tag Manager, and Google Analytics. I am also available for hire, so if you need help with any of these, feel free to get in touch.

Leave a Reply

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