Error Pages & Google Analytics [UPDATE]
Yesterday I wrote about tracking error pages with Google Analytics _trackEvent. I suggested _trackEvent over _trackPageview for it has the ability to add different dimensions to the event and you wouldn’t want 404 pages to increase your pageview count. Tim (Leighton-Boyce) pointed out that a 404 is part of the visitor session, you should be able to track if people bounce on 404 or click through on suggested links or perhaps even use a search box. A very fair point and I stand corrected. I would definitely add the _trackPageview line to the GA tracking code.
Goal Tracking
Having a short discussion on the topic, Tim stated: “Why not use goal tracking for the 404′s?” – Yeah, why not? Goals not only offer valuable metrics such as the conversion rate, but also valuable insights such as the reverse goal path and intelligent alerts . Tim was unsure about tracking the events to use the reverse goal path report, but I can verify this is possible. This way you are able to point out the path which led to the 404. Some amazing stuff!
So get your ‘track’ on and start tracking your 404′s with pageview and event-tracking. Make sure you link those events to a goal type. I’ve personally set up an complete error profile to experiment more with Tim’s suggestions combined with the event-tracking and I’ll see if it will acquire some valuable new insights. The new tracking cookie for tracking the error pages would look like this:
<script type="text/javascript">// <![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackEvent', 'Error', '404', 'page: ' + document.location.pathname + document.location.search + ' ref: ' + document.referrer, true]);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// ]]></script>
Good luck and big thanks to Tim for the new insights!
If you have any new ideas, please so share them with me in the comments!
Update: We just keep customizing the code! André Scholten suggested the use of the noninteraction parameter in _trackEvent. This way the event is excluded from bounce-rate calculations and does not affect your bounce-rate. It’s set by adding the parameter ’true’ at the end of the trackevent, as in the example above. Thanks André!

11 Comments
André Scholten
27/03/2012The same comment here as well:
You could add an extra “true” parameter to the call so the event won’t count as a user hit, and doesn’t affect your bouncerate.
Ralph van der Pauw
27/03/2012Thanks André, that’s a very good suggestion. The noninteraction parameter, I forgot about that one!
André Scholten
27/03/2012So now you have to write another update
Ralph van der Pauw
27/03/2012Damn you!
Fixed!
Tim Leighton-Boyce
27/03/2012This is great to see. Thank you for sharing the code here and on your previous post. I’ve found tracking 404s to be very valuable over time. It’s not a very exciting metric. But it makes a big difference to people visiting sites.
Ralph van der Pauw
27/03/2012Well said Tim, it has an impact on the user experience as well as the strength of your (SEO) linkstructure. Definitely something to track and take into account!.
Gerry White
27/03/2012Wow – I have always just taken the surprisingly lazy method of page title, making sure the page title is distinct allows you to go through the page titles report and seeing a list of all the 404 pages, it also gives you pathing, referalls etc.. which I am not sure track event will …
Oh and create a tech / error dashboard which also includes page load speeds etc.. for various areas …!
Ralph van der Pauw
27/03/2012Thank you Gerry! The
‘page: ‘ + document.location.pathname + document.location.search + ‘ ref: ‘ + document.referrer
line makes it possible to have both the page and the referal in an event-variable.
I totally agree about the dashboard. Currently I am experimenting a lot with page load speeds and a custom dashboard has been a very helpful tool.
Marine Pina Urrútia
21/04/2012A very impressive article. Well prepared. Very motivating!! Go off on to facilitate way
Michael Hayes
13/05/2013Great article, but you’ve created a new error by adding the non-interaction parameter to the event, as before it there should be a value parameter (e.g. 0)
Ralph
13/05/2013Hi Michael,
The developer documentation states that the _trackevent command requires a boolean:
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
Did you had problems setting it up?