<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,6 +6,7 @@ A Google Analytics plugin for jQuery that:
 
 * improves page load times by deferring the loading of Google Analytics to after the page has been loaded.
 * simplifies event and link tracking.
+* helps you track error pages (404, 500) as described &quot;here&quot;:http://www.google.com/support/analytics/bin/answer.py?hl=en&amp;answer=86927.
 
 h2. Installation
 
@@ -24,19 +25,19 @@ h3. Usage
 
 With the script loaded you now have access to these new methods:
 
-* $.googleAnalytics('UA-XXX-XXX') - Adds Google Analytics tracking to the page it's called from. By default, the loading of Google analytics is done after the onload event.
+* $.trackPage('UA-XXX-XXX') - Adds Google Analytics tracking to the page it's called from. By default, the loading of Google analytics is done after the onload event.
 * $.('selector').track - Used in combination with jQuery selectors to add click tracking, or tracking of other jQuery events, to matching elements. For example: $('selector').track() 
 * $.trackEvent - Used for custom event tracking. Same as _pageTracker.trackEvent, but checks that analytics isn't blocked. For example: $.trackEvent('category', 'action', 'label')
 
 h4. Deferred loading of Google Analytics
 
-To enable Google Analytics add a call to $.googleAnalytics inside the head tag:
+To enable Google Analytics add a call to $.trackPage inside the head tag:
 
 &lt;pre&gt;
   &lt;code&gt;
   &lt;head&gt;
     &lt;script type=&quot;text/javascript&quot;&gt;
-    $.googleAnalytics('UA-YOUR_ACCOUNT_ID')
+    $.trackPage('UA-YOUR_ACCOUNT_ID')
     &lt;/script&gt;
   &lt;/head&gt;
   &lt;/code&gt;
@@ -47,7 +48,7 @@ To improve page load times, the script defers the loading of the Google Analytic
 &lt;pre&gt;
   &lt;code&gt;
 	&lt;script type=&quot;text/javascript&quot;&gt;
-  $.googleAnalytics('UA-YOUR_ACCOUNT_ID', true)
+  $.trackPage('UA-YOUR_ACCOUNT_ID', false)
 	&lt;/script&gt;
   &lt;/code&gt;
 &lt;/pre&gt;
@@ -90,6 +91,22 @@ The third example selects links located inside the &quot;complex div&quot; and uses the li
 
 See index.html for complete examples.
 
+h4. Tracking 404 and 500 errors
+
+This plugin implements tracking of error pages &quot;as described on the Google Analytics Help pages&quot;:
+http://www.google.com/support/analytics/bin/answer.py?hl=en&amp;answer=86927
+
+To track an error, simply set the third parameter to the response code, as shown in this example:
+
+&lt;pre&gt;
+  &lt;code&gt;
+	&lt;script type=&quot;text/javascript&quot;&gt;
+  $.trackPage('UA-YOUR_ACCOUNT_ID', true, 404); // Track a 404 error
+  &lt;/script&gt;
+  &lt;/code&gt;
+&lt;/pre&gt;
+
+
 h4. Custom event tracking
 
 You can also track events by calling the trackEvent method:</diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,8 @@
 		&lt;script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
 		&lt;script src=&quot;jquery.google-analytics.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
     &lt;script type=&quot;text/javascript&quot;&gt;
-      // Track page views
-      var pageTracker = $.googleAnalytics('UA-1079755-4')
+      // Track page, defer loading, track as 404 error
+      $.trackPage('UA-1079755-4', {status_code: 404})
     &lt;/script&gt;
 	&lt;/head&gt;
 	&lt;body&gt;
@@ -16,7 +16,7 @@
     &lt;pre&gt;
 // Load Google Analytics script and track page views
 &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
-   $.googleAnalytics('UA-XXX-XXX')
+   $.trackPage('UA-XXX-XXX')
 &amp;lt;/script&amp;gt;
     &lt;/pre&gt;
     &lt;/code&gt;</diff>
      <filename>index.html</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,10 @@
 * A jQuery plugin that makes it easier to implement Google Analytics tracking, including event and link tracking.
 *
 * Adds the following methods to jQuery:
-* - $.googleAnalytics() - Adds Google Analytics tracking to the page it's called from.
+* - $.trackPage() - Adds Google Analytics tracking to the page it's called from.
 * - $('a').track() - Adds click tracking to elements.
 * - $.trackEvent() - Tracks an event using the given parameters. 
+* - $.timePageLoad() - Measures the time it takes  an event using the given parameters. 
 *
 * Features:
 *
@@ -42,7 +43,7 @@
 * Credits:
 *   - http://google.com/analytics: 
 *   - http://lyncd.com: 
-*       The googleAnalytics method was found here http://lyncd.com/2009/03/better-google-analytics-javascript/ and improved on slightly.
+*       The trackPage method was found here http://lyncd.com/2009/03/better-google-analytics-javascript/ and improved on slightly.
 *
 */
 
@@ -56,18 +57,23 @@
    * Example:
    *
    *  &lt;script type=&quot;text/javascript&quot;&gt;
-   *    $.googleAnalytics('UA-xxx-xxx');
+   *    $.trackPage('UA-xxx-xxx', options);
    *  &lt;/script&gt;
    *
    * Parameters:
    *
    *  account_id - Your Google Analytics account ID.
-   *  onload - If false, the Google Analytics code is loaded when this method is called instead of on window.onload.
+   *  options - An associative array containing one or more optional parameters:
+   *    - onload - If false, the Google Analytics code is loaded when this method is called instead of on window.onload.
+   *    - status_code - The HTTP status code of the current server response. If this is set to something other than 200 then the page is tracked as an error page. See this page for details: http://www.google.com/support/analytics/bin/answer.py?hl=en&amp;answer=86927
    *
    */
-  $.googleAnalytics = function(account_id, onload) {
+  $.trackPage = function(account_id, options) {
     var host = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
     var script;
+
+    // Use default options, if necessary
+    var settings = $.extend({}, {onload: true, status_code: 200}, options);
     
     script    = document.createElement('script');
     script.src  = host + 'google-analytics.com/ga.js';
@@ -76,12 +82,20 @@
     
     function init_analytics() {
       if (!script.onloadDone) {
+        debug('Google Analytics loaded');
+
         script.onloadDone = true;
 
         try {
           pageTracker = _gat._getTracker(account_id);
-          pageTracker._trackPageview();
-          debug('Google Analytics loaded');
+
+          if(settings.status_code == null || settings.status_code == 200) {
+            pageTracker._trackPageview();
+          } else {
+            debug('Tracking error ' + settings.status_code);
+            pageTracker._trackPageview(&quot;/&quot; + settings.status_code + &quot;.html?page=&quot; + document.location.pathname + document.location.search + &quot;&amp;from=&quot; + document.referrer);
+          }
+          
         } catch(err) {
           debug('Google Analytics failed to load: ' + err);
         }
@@ -105,7 +119,7 @@
     }
 
     // Enable tracking when called or on page load?
-    if(onload == true || onload == null) {
+    if(settings.onload == true || settings.onload == null) {
       $(window).load(load_script);
     } else {
       load_script();</diff>
      <filename>jquery.google-analytics.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e6fda04d5cf8446146f44e14e8964490de59ed63</id>
    </parent>
  </parents>
  <author>
    <name>Christian Hellsten</name>
    <email>christian.hellsten@gmail.com</email>
  </author>
  <url>http://github.com/christianhellsten/jquery-google-analytics/commit/1ccb8d8127fbf77608793c061601f81485b6378f</url>
  <id>1ccb8d8127fbf77608793c061601f81485b6378f</id>
  <committed-date>2009-03-23T09:41:55-07:00</committed-date>
  <authored-date>2009-03-23T09:41:55-07:00</authored-date>
  <message>Renamed googleAnalytics to trackPage. Added tracking of error pages</message>
  <tree>9afda40d36afcf854c4a889205c23ec7b59b62e2</tree>
  <committer>
    <name>Christian Hellsten</name>
    <email>christian.hellsten@gmail.com</email>
  </committer>
</commit>
