Detect pages with 404 errors

You may come across 404 errors if you have changed URLs on your website and forgotten to update them with the new URLs.

Setting up an event tag

The procedure for setting up an event tag is as follows:

  1. Create a «Google Analytics: Universal Analytics» tag of the «event» type It must be configured to log the URL that causes an error. To do this: for «Category», enter «Errors»; for «Actions», enter «404 error»; and for »Event Name’, enter the variable {{Page URL}} Add your Google Analytics parameter

Page detection and triggering

To find out whether a user is on a 404 error page or not, you need to identify which page they are on. If they are on that error page, you need to report the page’s URL by triggering the tag.

Compare page titles

To retrieve a page’s title, you must:

  1. Create a custom variable in GTM. Go to «Variables» and click «New». Create a JavaScript variable using the term «document.title». Save it and name it «Page Title».»

Creating the trigger

You know how to retrieve a page’s title; now you can create a trigger:

  • Create a «Page View» trigger, then set the variable to «Page Title», «contains» and the page title: «This page does not exist»

This trigger will only be activated on 404 error pages. You can now deploy a new version of your container by configuring the tag with this trigger.

Would you like to know how the emails and calls you receive come from your website? Tune in to the next episode.

AdWords and Digital Marketing Agency in Marseille – Headline trigger

Created by Vaniseo, your web agency in Marseille

Contact us

Our team will get back to you within 24 hours

Fancy finding out how much each channel brings in?

Google Analytics 4, conversions, dashboards: we make your figures easy to understand.