<?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>Joshua + Schaible + Blog &#187; Coding</title>
	<atom:link href="http://www.joshuaschaible.com/blog/tag/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joshuaschaible.com/blog</link>
	<description>My World.</description>
	<lastBuildDate>Fri, 14 May 2010 18:19:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Track Outgoing Links With jQuery And G-Analytics!</title>
		<link>http://www.joshuaschaible.com/blog/track-outgoing-links-with-some-jquery-and-google-analytics-easy/</link>
		<comments>http://www.joshuaschaible.com/blog/track-outgoing-links-with-some-jquery-and-google-analytics-easy/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 21:35:48 +0000</pubDate>
		<dc:creator>Joshua Schaible</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Google Analytics]]></category>

		<guid isPermaLink="false">http://www.joshuaschaible.com/blog/?p=1676</guid>
		<description><![CDATA[
This is an explanation of how you can track single outgoing links with some jQuery and Google Analytics. Why would you do this? Say your selling an iPhone app, and you have a few ads/links on your own site linking to that iPhone app in iTunes, and you want to know how many people are [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-1700" style="border: 2px solid #666666;" title="analytics" src="http://www.joshuaschaible.com/blog/wp-content/uploads/2009/09/analytics1.jpg" alt="analytics" width="500" height="150" /></p>
<p style="text-align: left;">This is an explanation of how you can track single outgoing links with some<a href="http://jquery.com/" target="_blank"> jQuery</a> and <a href="http://google.com/analytics">Google Analytics</a>. Why would you do this? Say your selling an iPhone app, and you have a few ads/links on your own site linking to that iPhone app in iTunes, and you want to know how many people are clicking on that ad vs. the people buying the app. Sound like something you need? Lets get started.</p>
<p><span id="more-1676"></span></p>
<p style="text-align: left;">If you don&#8217;t have a Google Analytics account, go make one and come back once you have installed the tracking code in the footer of your website. Don&#8217;t worry, this post will wait for you.</p>
<h3 style="text-align: left;">Step #1</h3>
<p>Enter this into the &lt;head&gt; of your website if your not already using the jQuery library.</p>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a> <span class="kw3">src</span><span class="sy0">=</span><span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/script.html"><span class="kw2">script</span></a>&gt;</span></div>
</div>
<h3 style="text-align: left;">Step #2</h3>
<p>Now go to the specific link that you want to track the clicks on. Your basic html link will probably look like this:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st0">&quot;http://joshuaschaible.com/myiphoneapp&quot;</span> target<span class="sy0">=</span><span class="st0">&quot;_blank&quot;</span><span class="sy0">&gt;</span>Buy My App<span class="sy0">!&lt;/</span>a<span class="sy0">&gt;</span></div>
</div>
<p>All we have to do is add one  javascript variable:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">onClick<span class="sy0">=</span><span class="st0">&#8216;javascript: pageTracker._trackPageview(&quot;/outgoing/NAME-HERE&quot;);&#8217;</span></div>
</div>
<p><span>Add the onClick function and your link will look like this: </span></p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="sy0">&lt;</span>a onClick<span class="sy0">=</span><span class="st0">&#8216;javascript: pageTracker._trackPageview(&quot;/outgoing/NAME-HERE&quot;);&#8217;</span> href<span class="sy0">=</span><span class="st0">&quot;http://joshuaschaible.com/myiphoneapp&quot;</span> target<span class="sy0">=</span><span class="st0">&quot;_blank&quot;</span><span class="sy0">&gt;</span>Buy My App<span class="sy0">!&lt;/</span>a<span class="sy0">&gt;</span></div>
</div>
<p>Where it says &#8220;NAME-HERE&#8221; you should put a name or identifier of what your tracking. For example:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="sy0">&lt;</span>a onClick<span class="sy0">=</span><span class="st0">&#8216;javascript: pageTracker._trackPageview(&quot;/outgoing/myiphoneapp&quot;);&#8217;</span> href<span class="sy0">=</span><span class="st0">&quot;http://joshuaschaible.com/myiphoneapp&quot;</span> target<span class="sy0">=</span><span class="st0">&quot;_blank&quot;</span><span class="sy0">&gt;</span>Buy My App<span class="sy0">!&lt;/</span>a<span class="sy0">&gt;</span></div>
</div>
<h3>Step #3</h3>
<p><span>Log into Google Analytics. In the left hand side go to &#8220;Content&#8221; and then to &#8220;Top Content.&#8221;<br />
</span></p>
<p><a href="http://www.joshuaschaible.com/blog/wp-content/uploads/2009/09/Picture-2.png" rel="lightbox[1676]"><span><img class="alignnone size-full wp-image-1734" title="Picture 2" src="http://www.joshuaschaible.com/blog/wp-content/uploads/2009/09/Picture-2.png" alt="Picture 2" width="258" height="372" /></span></a></p>
<p><span>At the bottom there will be a search box which says &#8220;Filter Page.&#8221; Type in &#8220;outgoing&#8221;. It should then show you all records of /outgoing/ clicks. According to our example it should say &#8220;/outgoing/myiphoneapp/ and show you the amount of clicks and the amount of unique page views.</span></p>
<div id="attachment_1745" class="wp-caption alignnone" style="width: 310px"><a href="http://www.joshuaschaible.com/blog/wp-content/uploads/2009/09/Picture-31.png" rel="lightbox[1676]"><img class="size-medium wp-image-1745" title="Picture 3" src="http://www.joshuaschaible.com/blog/wp-content/uploads/2009/09/Picture-31-300x47.png" alt="Picture 3" width="300" height="47" /></a><p class="wp-caption-text">Click to enlarge!</p></div>
<h3 style="text-align: left;">Remember&#8230;</h3>
<p><span>Google Analytics doesn&#8217;t work in real time yet, so you may have to wait up to 24 hours to start seeing the click numbers go up!</span><span> Hope you enjoyed! Please comment with any questions!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshuaschaible.com/blog/track-outgoing-links-with-some-jquery-and-google-analytics-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
