Email icon

Get email alerts for 404 errors on your website

Google Analytics email alerts are a great way to keep tabs on any anomalies on your sites, particularly if you manage large sites or multiple sites.

They’re simple to set up (here’s a quick overview from Google) and can be a real lifesaver as I’ve discovered.

The most useful email alert I’ve ever set up was to notify me if there was an unusual spike in 404 page not found errors.

You’re always going to have some 404 errors – people misspelling a URL, or even bots trying find your login pages (we run Drupal sites and see a lot of traffic trying to hit WordPress associated URLs).

But you may occasionally see a sudden spike in 404 errors that may signal a serious problem – a link on your site is broken or a social media post, ad campaign or another website is sending traffic to the wrong place.

In that case, these email alerts can notify you of the problem so that you can fix the broken link, set up redirects or contact the referrer to fix their link.

Below is a quick tutorial on setting up alerts through Google Analytics and Tag Manager.

Tutorial

  1. First, we’ll need to set up a custom event using Google Tag Manager. We’ll create a new trigger to fire when someone hits a 404 error. Depending on how your site is configured, you can usually set up the trigger to fire on some pageviews where the page path starts with or contains “404.” In this example, I set it up to fire when the page title contains “Page not found.”
  2. Next we’ll create a new tag to send a create a custom event in Google Analytics. For event category, name it something like “404 Error.” For the action, I selected the page path variable to identify which page is experiencing the error. For the label, I assigned the referrer variable, which can help identify where the traffic is coming from (this won’t work all the time, as some referral values will be “not set”).
  3. Publish your container to your live site. After a few hours check your Analytics account for hits for your new event under Behavior -> Events -> Top Events.
  4. In order to get a baseline for “acceptable” 404 errors vs legitimate broken links, monitor event hits closely every day for a week or so. Fix any broken links that can be fixed on your end.
  5. After this evaluation period, set up a new custom alert in Google Analytics. Go to Customization -> Custom Alerts -> Manage Custom Alerts -> New Alert. Here’s where your baseline info comes into play. I discovered this site averaged about 20-25 “acceptable” page not found errors a day, so more than 25 in a day usually signaled something was wrong. I configured my alert to email me when there were more than 25, but you can set it up based on percentage change. This may take a little experimentation.
  6. Alternatively, if you want a more detailed look at the 404 errors users hit on your site, you can create a custom report and have Google Analytics email you the report every day. To do this, go to Customization – > Custom Reports -> New Custom Report.
  7. Create a new report where the dimensions are Event Category, Action and Label. The metric is Total Events or Unique Events. Filter to only show events with the category “404 Error.” The benefit of the custom report is you can add additional dimensions to help determine where the traffic may be coming from if you are unsure.
  8. Save and view your report. Click Share to set up daily emails.

You may also like