<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jens Arps &#187; google</title>
	<atom:link href="http://jensarps.de/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://jensarps.de</link>
	<description></description>
	<lastBuildDate>Tue, 01 May 2012 12:00:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>dojox.analytics.Urchin for jQuery</title>
		<link>http://jensarps.de/2009/10/03/dojox-analytics-urchin-for-jquery/</link>
		<comments>http://jensarps.de/2009/10/03/dojox-analytics-urchin-for-jquery/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 17:28:41 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[Framework Peace]]></category>
		<category><![CDATA[Goodies to go]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://jensarps.de/?p=38</guid>
		<description><![CDATA[Or: Still ending the ga.js wait… It has become quiet here the last weeks – due to an awesome trip to Italy. Returning home, I decided to put Google Analytics on this page. As I always hate waiting for the ga.js to load while visiting websites, I wanted a mechanism to delay the load of [...]]]></description>
			<content:encoded><![CDATA[<p>Or: <em>Still</em> ending the ga.js wait…</p>
<p>It has become quiet here the last weeks – due to an awesome trip to Italy. Returning home, I decided to put Google Analytics on this page.</p>
<p>As I always hate waiting for the ga.js to load while visiting websites, I wanted a mechanism to delay the load of it. Why this is a good idea has been discussed often enough elsewhere, so we take it as fact. Peter Higgins once <a href="http://higginsforpresident.net/2008/06/google-analytics-after-onload/" target="_blank">wrote such a wrapper for dojo</a>, and as of dojo 1.3, it&#8217;s officially included in dojox (see <a href="http://alex.dojotoolkit.org/2009/04/ending-the-gajs-wait/" target="_blank">Alex Russel&#8217;s post</a>). But this WordPress theme runs jQuery, and I didn&#8217;t want to have two frameworks in one website – so I searched for something that did the job for jQuery.<br />
<span id="more-38"></span><br />
But I didn&#8217;t really find what I was looking for. Well, there <em>are</em> some jQuery plugins that provide functionality like I wanted. Some were overpowered, some poorly written – and in the end, they all relied on jQuery.getScript(). The problem is, that getScript() adds a random parameter to the GET call, so that the called script is never cached. While this <em>may</em> be useful for some situations, in this case it&#8217;s really annoying and undesireable. In addition, I liked the idea of dojox.analytics.Urchin to not really <em>wait</em> for the script to be loaded, but instead to go see every now and then if the _gat global variable is present, and to give up after some time in case something went wrong.</p>
<p>So I decided to &#8220;port&#8221; dojox.analytics.Urchin to jQuery. It works almost the same as it&#8217;s dojo origin, with two major differences: First, you can&#8217;t have several instances of it running, you call it directly via jQuery.urchin.load(args). Second, there&#8217;s an option waitForDOM, set to true as default, that delays the loading of ga.js until the DOM is ready. If you call jQuery.urchin.load() from within a jQuery(document).ready() block, set this to false.</p>
<p>Example? Here you go:</p>
<pre>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.urchin.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
jQuery.urchin.load({acct:'UA-111111-1'});
&lt;/script&gt;</pre>
<p>Or, if you need more options:</p>
<pre>&lt;script type="text/javascript"&gt;
$(document).ready(function() {
    // do some stuff
    // ...
    // load ga.js
    $.urchin.load({
        acct:'2234-2342',
        timeout: 8000,
        waitForDOM: false
    });
});
&lt;/script&gt;</pre>
<p>You can get the file here: <a href="http://jensarps.de/tests/jquery_analytics/jquery.urchin.js" target="_blank">jquery.urchin.js</a></p>
<p>Uncompressed version: <a href="http://jensarps.de/tests/jquery_analytics/jquery.urchin.uncompressed.js">jquery.urchin.uncompressed.js</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jensarps.de/2009/10/03/dojox-analytics-urchin-for-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

