Track and View 404 Errors with Google Analytics 4

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.

Ecommerce Marketing Automation

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


Table of contents

+ Show table of contents +


Video tutorial

If you prefer video content, here’s a tutorial from my Youtube channel.


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 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 the 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 easily check that by adding some non-sense in the URL. For example,

If you see a “Page not found” message (or some other 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 main 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 Page path dimension (it is 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.


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 || [];
  '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 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 > GA4 event.

Then select your existing GA4 configuration tag (1) and enter a name for this event (that clearly describes it), for example, 404_error (2), page_not_found, or something else. 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 > Configure > 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 404_error. 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 right away.

redirection wp plugin

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

Want to see what was the URL of the previous page 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 how you can track 404 errors with Google Analytics 4. The first option does not require any development – you can achieve the result just by using standard reports. The second one is to utilize Google Tag Manager and send 404 errors as events to Google Analytics 4.


Source link

30%* off! Big Savings For Your Small Business!


Please enter your comment!
Please enter your name here