Advanced 404 Not Found Error page usage with Google Analytics. This makes it very easy to diagnose and keep track of 404 Error messages from within google analytics. Enjoy!

NOTE:You will most definately want to check out and use the Google 404 Error Page.

Normal Google Analytics code on 404 error page

This default setup for 404 error pages makes it very difficult to find and analyze 404 error page usage stats in Google Analytics

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-732153-7"; urchinTracker();
</script>

Advanced 404 Error Page Setup for Google Analytics urchin

Since the urchinTracker function has 1 argument which is called "page", this code tells it that the "page" should be /404/?page-not-found=page-requested&linked-from=referrer.

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-732153-7";
urchinTracker("/404/?page-not-found=" + _udl.pathname + _udl.search + "&linked-from=" + _ubd.referrer);
</script>

My Wordpress 404.php page

Note also how I have used the googlebot and robots meta tags to tell robots not to index or follow links in this page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head profile="http://gmpg.org/xfn/11">
    <title>404 Error - Page Not Found</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="googlebot" content="noarchive,noindex,nofollow" />
    <meta name="robots" content="noarchive,noindex,nofollow" />
    <link rel="stylesheet" type="text/css" href="http://www.askapache.com/wp-content/themes/apachehtaccess-10/style.css" media="screen" />
    <script src="http://s.askapache.net/j/askapache.js?v924" type="text/javascript"></script>
    <link rel="shortcut icon" href="http://www.askapache.com/favicon.ico" type="image/x-icon" />
</head>
<body class="notfound404">
<h1 id=""> <a class="sl" href="#"></a></h1>
<div class="a">
    <div class="b">
        <h2 id="Ooops_requested_page"><span style="color:red;">Ooops!</span><strong> - The requested page could not be found.</strong> <a class="sl" href="#Ooops_requested_page"></a></h2>
    </div>
</div>
<p id="FootW">&copy;2007 AskApache Privacy Policy - Terms of Service - <a class="ICOdreamhost" rel="nofollow" href="http://www.dreamhost.com/r.cgi?211825">DreamHost Hosting</a></p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
_uacct = "UA-732153-7";
urchinTracker("/404/?page-not-found=" + _udl.pathname + _udl.search + "&linked-from=" + _ubd.referrer);
</script>
</body>
</html>

Google Analytics urchin.js

//-- Google Analytics Urchin Module
//-- Copyright 2005 Google, All Rights Reserved.

//-- Urchin On Demand Settings ONLY
var _uacct="";      // set up the Urchin Account
var _userv=1;      // service mode (0=local,1=remote,2=both)

//-- UTM User Settings
var _ufsc=1;      // set client info flag (1=on|0=off)
var _udn="auto";    // (auto|none|domain) set the domain name for cookies
var _uhash="on";    // (on|off) unique domain hash for cookies
var _utimeout="1800";     // set the inactive session timeout in seconds
var _ugifpath="/__utm.gif";  // set the web path to the __utm.gif file
var _utsp="|";      // transaction field separator
var _uflash=1;      // set flash version detect option (1=on|0=off)
var _utitle=1;      // set the document title detect option (1=on|0=off)
var _ulink=0;      // enable linker functionality (1=on|0=off)
var _uanchor=0;      // enable use of anchors for campaign (1=on|0=off)
var _utcp="/";      // the cookie path for tracking
var _usample=100;    // The sampling % of visitors to track (1-100).

//-- UTM Campaign Tracking Settings
var _uctm=1;      // set campaign tracking module (1=on|0=off)
var _ucto="15768000";    // set timeout in seconds (6 month default)
var _uccn="utm_campaign";  // name
var _ucmd="utm_medium";    // medium (cpc|cpm|link|email|organic)
var _ucsr="utm_source";    // source
var _uctr="utm_term";    // term/keyword
var _ucct="utm_content";  // content
var _ucid="utm_id";    // id number
var _ucno="utm_nooverride";  // don't override

//-- Auto/Organic Sources and Keywords
var _uOsr=new Array();
var _uOkw=new Array();
_uOsr[0]="google";  _uOkw[0]="q";
_uOsr[1]="yahoo";  _uOkw[1]="p";
_uOsr[2]="msn";    _uOkw[2]="q";
_uOsr[3]="aol";    _uOkw[3]="query";
_uOsr[4]="aol";    _uOkw[4]="encquery";
_uOsr[5]="lycos";  _uOkw[5]="query";
_uOsr[6]="ask";    _uOkw[6]="q";
_uOsr[7]="altavista";  _uOkw[7]="q";
_uOsr[8]="search";  _uOkw[8]="q";
_uOsr[9]="netscape";  _uOkw[9]="s";
_uOsr[10]="cnn";  _uOkw[10]="query";
_uOsr[11]="looksmart";  _uOkw[11]="qt";
_uOsr[12]="about";  _uOkw[12]="terms";
_uOsr[13]="mamma";  _uOkw[13]="query";
_uOsr[14]="alltheweb";  _uOkw[14]="q";
_uOsr[15]="gigablast";  _uOkw[15]="q";
_uOsr[16]="voila";  _uOkw[16]="kw";
_uOsr[17]="virgilio";  _uOkw[17]="qs";
_uOsr[18]="live";  _uOkw[18]="q";
_uOsr[19]="baidu";  _uOkw[19]="wd";
_uOsr[20]="alice";  _uOkw[20]="qs";
_uOsr[21]="seznam";  _uOkw[21]="w";
_uOsr[22]="yandex";  _uOkw[22]="text";
_uOsr[23]="najdi";  _uOkw[23]="q";

//-- Auto/Organic Keywords to Ignore
var _uOno=new Array();
//_uOno[0]="urchin";
//_uOno[1]="urchin.com";
//_uOno[2]="www.urchin.com";

//-- Referral domains to Ignore
var _uRno=new Array();
//_uRno[0]=".urchin.com";
Google Analytics urchin.js
Urchin On Demand Settings ONLY
_uacct  =""       set up the Urchin Account
_userv  =1       service mode (0 =local,1 =remote,2 =both)

UTM User Settings
_ufsc  =1       set client info flag (1 =on|0 =off)
_udn ="auto"     (auto|none|domain) set the domain name for cookies
_uhash ="on"     (on|off) unique domain hash for cookies
_utimeout ="1800"      set the inactive session timeout in seconds
_ugifpath ="/__utm.gif"   set the web path to the __utm.gif file
_utsp ="|"       transaction field separator
_uflash =1       set flash version detect option (1 =on|0 =off)
_utitle =1       set the document title detect option (1 =on|0 =off)
_ulink =0       enable linker functionality (1 =on|0 =off)
_uanchor =0       enable use of anchors for campaign (1 =on|0 =off)
_utcp ="/"       the cookie path for tracking
_usample =100     The sampling % of visitors to track (1-100).

UTM Campaign Tracking Settings
_uctm =1       set campaign tracking module (1 =on|0 =off)
_ucto ="15768000"     set timeout in seconds (6 month default)
_uccn ="utm_campaign"   name
_ucmd ="utm_medium"     medium (cpc|cpm|link|email|organic)
_ucsr ="utm_source"     source
_uctr ="utm_term"     term/keyword
_ucct ="utm_content"   content
_ucid ="utm_id"     id number
_ucno ="utm_nooverride"   don't override

Google

Comments