In March, Blogger added some features for searching related preferences. One of which is Custom Page Not Found message, you can put some simple text in it showing your humour. But there is more from it, you can actually write HTML/JavaScript code in it.

Last night, an idea suddenly came to me. What if someone has broken links, like ones caused by some URL encoding issue. How do you know about it? By default template, Blogger will insert the Google Analytics with your UA id, even the page is an error page. And those 404 will appear in Google Analytics report, the problem is they will be buried with other normal requests.

If you want to track those 404 pages in Google Analytics, you can use event tracking to mark them, just insert the following code at the end of your Custom Page Not Found:


<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackEvent', 'Error', '404']);
</script>

Since Blogger will insert Google Analytics tracking code, we can leave that part out of this code. Pushing data in to the _gaq will work. You will need to replace the UA id.

I have created a custom report, you can use it to create one of your own. Don’t forget to set up an email update, so you don’t have to check it up regularly on website.

If you want to more simpler version, which don’t mix with events, you can create a special profile and change the last two lines to be


_gaq.push(['_trackPageview']);

That profile will only contains 404 pages.