FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home  »  Google  »  Advanced Google Analytics 404 Error Page

by 3 comments

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://static.askapache.com/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><a href="http://www.askapache.com/"></a></h1>
<div class="a">
    <div class="b">
        <h2><span style="color:red;">Ooops!</span><strong> - The requested page could not be found.</strong></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

Tags

July 1st, 2007

Comments Welcome

  • Binny V A

    How do I access this info from Google Analytics?

  • http://www.askapache.com/ AskApache

    Just surf to the area that lets you view hits to directories.. /404/ will show up allowing you to see all of the detail you crave.

  • AlexJB

    dunno how old this post is - it came up high in google searching for 404 tracking.

    As of 2010-Apr, the code listed here looks out of date. Check this Google article instead:
    http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=86927

Popular Articles
My Online Tools

Related Articles
Newest Posts
Twitter


  •  t.co/ShKrGdqXuJ 
  • RUN GCC! This is a typical shirt I wear, from the  t.co/46LYbFr4k2  shop. A clerk at the LQ recognized it!  t.co/jjmT0dkCPu 
  • Merlin the Magician  t.co/iMmRbanUi4 
  • ROGUE CODE - Latest novel from @markrussinovich  t.co/apkn0LoPIt 
  • RTFM - surprisingly very helpful and way more comprehensive than it looks! @redteamfieldman #pwnAllTheThings  t.co/xiaJ5g0aC9 
  • Dear Hacker - Letters to the Editor of 2600, from Emmanuel Goldstein  t.co/JCfLab7FAJ 
  • The Mythical Man-Month - Essays on Software Engineering, by Frederick P. Brooks, Jr.  t.co/ilWN5GHElr 
  • "where wizards stay up late" - The Origins of the Internet. Favorite book detailing the birth of the net and IMPs  t.co/gY9VTGJgZz 
  • ZERO DAY - read before Trojan horse  t.co/pPMLGDJv8P 
  • Trojan Horse, a novel!  t.co/Hf8EtYaZVa 
  • The Hacker Playbook - very nice high level overview of attacks  t.co/lHwNVWi61u 
  • Clean Code - A Handbook of Agile Software Craftsmanship  t.co/hnJX0x1qIc 
  • Secrets of the JavaScript Ninja - By my absolute favorite JS hacker John Resig!  t.co/tZ42ljmcCl 
  • Hacking Exposed 7: Network Security Secrets & SolutionsMy all time favorite, basic but thorough and accurate.  t.co/jycW0RDVtZ 

Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two. See my article, On Hacking.
-- Richard M. Stallman






[hide]

It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

| Google+ | askapache

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service

↑ TOPMain