Blog

Unleash the Power of Google Analytics (6): 404 Tracking

,

Google Analytics - 404 Tracking

One of the most useful ways of using Google Analytics to identify potential problems on your website is by implementing 404 tracking. A 404 page indicates that your server could not find the resource requested by your visitor, but only tracking can tell you why.

Analytics deployments often overlook this simple, yet effective method of identifying broken links (even those off site), along with missing pages and lost opportunities. But by adding a very small piece of custom code, you can reveal a wealth of information about the 404 pages that your users are seeing.

1) Add the custom tracking code to the 404 page template

Assuming that the 404 pages on your site are currently missing the Google Analytics Tracking Code (GATC), add the following code to the page – this is the standard ga.js code, with an amended line, indicated in bold.

 

 

 

 

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
try {
var pageTracker = _gat._getTracker(“UA-xxxxxxx-x”);
pageTracker._trackPageview(“/404.html?page=” + document.location.pathname + document.location.search + “&from=” + document.referrer);} catch(err) {}</script>

 

 

The code sends a virtual page view of “/404.html?page=[pagename.html?queryparameter]&from=[referrer]” to Analytics, where pagename.html?queryparameters shows the missing page name, and referrer represents the page URL the user came from before they landed on your 404 page.

2) Take a look at the incoming data

Log in to your Google Analytics control panel and look for /404.html in the Top Content report. This will display 404 page statistics, along with the locations of the missing pages and the referring information.

Find Page - 404.html

Once the code has been collecting 404 visit data for a while, you should see entries that resemble the following appear in the top content report.

404 entries

In this example, the /404.html serves as an identifier so that we can see that the pages are 404s (and filter them using the ‘filter page’ feature in Analytics). Next, the page= section shows the address that the 404 appeared at – in this case a gif image. Finally, the from= section shows the source of the traffic – this time it was a referring site called ‘mybrowserbar.com’.

This information is valuable in the following situations.

  • Finding any broken links on-site from old or redundant pages. A page may have been renamed, removed or inadvertently broken. This is especially common when a number of people have access to the CMS or the server, and make frequent changes.
  • Discovering where redirects can capture traffic from a referring site’s dead link. A new site or URL rewrite will mean that existing links point to missing pages. You need to put 301 redirects in place, and 404 tracking will help you identify any that you have missed.
  • PPC destination URL problems (i.e. when a PPC landing page doesn’t exist and paid traffic is being directed to a 404 page). Often these expensive errors go unnoticed for some time, as advertisers tend not to click their own PPC adverts.

The majority of 404s (except for those that are the result of mistyped URLs) can prevented by using one of the following methods, depending on the reason for the 404 status.

  • Implementing 301 redirects
  • Adjusting PPC keyword and advert destination URL’s
  • Fixing broken links on site
  • Requesting that broken links on external sites are directed to a new page
  • Creating appropriate new pages and content on topics your users will expect to find
  • Developing new URL-specific landing pages
  • Generating dynamic 404s that include relevant search results

Top tip: Set up filters to segment 404 tracking into a profile of its own – this way, it is clear to see from the Analytics overview page if there has been a significant, recent increase in 404 errors.

404 profile

 

Subscribe to our blog and follow this Analytics series

More on this subject