<?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>UK Web Marketing Services &#187; analytics</title>

<link rel="stylesheet" href="http://www.iwanttoknowif.com/wp-content/plugins/cms-navigation/css/cms-navigation.css?ver=0.3" type="text/css" media="all" />
	<atom:link href="http://www.iwanttoknowif.com/category/analytics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iwanttoknowif.com</link>
	<description>Search Engine Optimisation, Pay per Click, Website Design &#38; Social Media</description>
	<lastBuildDate>Wed, 23 Nov 2011 09:13:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Turn Google Analytics Into Your Own Rank Tracker Using Custom Variables</title>

<link rel="stylesheet" href="http://www.iwanttoknowif.com/wp-content/plugins/cms-navigation/css/cms-navigation.css?ver=0.3" type="text/css" media="all" />
		<link>http://feedproxy.google.com/~r/seomoz/~3/XyE68emin-o/tracking-organic-ranking-in-google-analytics-with-custom-variables</link>
		<comments>http://feedproxy.google.com/~r/seomoz/~3/XyE68emin-o/tracking-organic-ranking-in-google-analytics-with-custom-variables#comments</comments>
		<pubDate>Wed, 29 Sep 2010 21:02:23 +0000</pubDate>
		<dc:creator>MikeCP</dc:creator>
				<category><![CDATA[analytics]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[rank tracking]]></category>
		<category><![CDATA[seomoz]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Posted by MikeCPToday I want to talk about tracking organic ranking in Google Analytics. Previously, we were able to determine the page from which a Google organic click was coming from (detailed on the Distilled blog by Will Critchlow). This was nice ... <span style="color:#777"> . . . &#8594; Read More: <a href="http://feedproxy.google.com/~r/seomoz/~3/XyE68emin-o/tracking-organic-ranking-in-google-analytics-with-custom-variables">How to Turn Google Analytics Into Your Own Rank Tracker Using Custom Variables</a></span>]]></description>
			<content:encoded><![CDATA[<p class="syndicated-attribution">Syndicated From: <a href="http://www.seomoz.org/blog">SEOmoz Daily SEO Blog</a> http://feedproxy.google.com/~r/seomoz/~3/XyE68emin-o/tracking-organic-ranking-in-google-analytics-with-custom-variables

</p>
<p>Posted by <a rel="nofollow" target="_blank" href="http://www.seomoz.org/users/view/127823" rel="nofollow" >MikeCP</a></p>
<p>Today I want to talk about tracking organic ranking in Google Analytics. Previously, we were able to determine the page from which a Google organic click was coming from (detailed on the <a rel="nofollow" target="_blank" href="http://www.distilled.co.uk/blog/seo/tracking-referrals-from-second-page-of-google-in-google-analytics/" rel="nofollow" >Distilled blog</a> by Will Critchlow). This was nice because we could append this to the end of our keywords in Google Analytics for some interesting data (André Scholten&#8217;s post at <a rel="nofollow" target="_blank" href="http://yoast.com/track-seo-rankings-google-analytics/" rel="nofollow" >Yoast.com</a> has a step by step) as seen below.</p>
<p style="text-align: center;"><img src="http://www.seomoz.org/img/upload/rankings-example.png" alt="Keyword Page Rankings" width="271" height="178" /><br />
<em>Image courtesy of Yoast.com</em></p>
<p>This solution provides limited utility, and if you&#8217;re like me, you implemented it, maybe checked it out once in a while, but never really turned this into actionable or otherwise meaningful data. I&#8217;m going to detail how rank tracking in Google Analytics can be made a lot more useful thanks to custom variables and a change in Google&#8217;s referring URLs. But first&#8230;</p>
<h3>Some History</h3>
<p>When Google began testing an AJAX search interface in early 2009 there was a <a rel="nofollow" target="_blank" href="http://searchengineland.com/google-ajax-search-results-death-to-search-term-tracking-16431" rel="nofollow" >flurry of concern</a> that it could mean the end of traditional rank tracking, web analytics packages, and I&#8217;m sure someone said SEO was dead, too. The concern wasn&#8217;t without merit; Google was serving results in AJAX with the URL pattern as <em>http://www.google.com/#q=keyword</em>, and most analytics packages ignored the hash and everything after.</p>
<p>Fast forward to September 8th, when Google introduced Google Instant. The AJAX SERP usage had been steadily increasing over time, but shot up in usage when Instant was rolled out. Fortunately for Omniture, WebTrends, and other third party analytics packages, Google worked out a way to pass the referrer information from the SERPs, rank tracking still works, and I&#8217;m still working as an SEO in a living industry.</p>
<p>As it turns out, Google includes even more information in the AJAX SERPs than they previously did, including one really interesting parameter: &#8220;cd=&#8221;. The <em>cd=</em> parameter contains the <em>exact ranking position</em> of the search listing, which makes for some really awesome possibilities, especially when paired with Google Analytics&#8217; custom variables.</p>
<h3>Why Custom Variables?</h3>
<p>Custom variables are a bit of an enigma to even advanced Analytics users. I&#8217;ll admit that I never really made much use of them in the past. You&#8217;ll often see examples where custom variables are used to track logged in vs. unlogged in users, which is definitely a great use. Rob Ousbey&#8217;s <a rel="nofollow" target="_blank" href="http://www.distilled.co.uk/blog/miscellaneous/6-cool-things-you-can-do-with-google-analytics-custom-variables/" rel="nofollow" >6 cool things YOU can do with custom variables</a> is a good set of examples to get your feet wet.</p>
<p>In André Scholten&#8217;s example above we&#8217;re using Google Analytics user defined value, isn&#8217;t that just as good a custom variable? Well, the difference depends on how you intend on using your data. With custom variables, you&#8217;re granted much more flexibility within Google Analytics for slicing and dicing data. For instance, through the use of either custom reporting or advanced segments with custom variables, I can pretty easily track how much revenue a keyword has brought in when ranked in the 2nd position, as opposed to the 4th. While this may be possible with the user defined variable, it would require quite a bit of work after an excel data dump.</p>
<p>Now, let&#8217;s get to business:</p>
<h3>The How</h3>
<p>Getting this properly set up was remarkably easy for me, and I have so very little programming knowledge, so I would imagine most wouldn&#8217;t have much issue. I used PHP, as I was working with a WordPress site, but I&#8217;m sure you crazy hackers can do the same in most any language.</p>
<p><strong>Update:</strong> <em>See Joost and André Scholten&#8217;s comments below for a JavaScript method of passing the cd= value</em></p>
<h4>Step One &#8211; Extract <em>cd=</em> Value from Referrer String</h4>
<p>I used this snippet to do this.</p>
<pre>&lt;?php preg_match("/cd\=(\d+)/",$_SERVER['HTTP_REFERER'], $matches);
$str = $matches[0];
preg_match("/(\d+)/",$str,$matches);
$rank = $matches[0] ?&gt;</pre>
<p><em>Please don&#8217;t make fun of my hacky coding</em></p>
<p>This assigns the <em>cd=</em> value to the <em>$rank</em> variable. We&#8217;ll reference this in&#8230;</p>
<h4>Step 2 &#8211; Call <em>cd=</em> Value in our Google Analytics snippet</h4>
<p>Now, we want to insert the custom variable call between the setAccount and trackPageview lines in our Analytics snippet (shown below using the asynchronous code):</p>
<pre>var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
  _gaq.push(['_setCustomVar',1,'Google_Ranking','$rank',2]);
  _gaq.push(['_trackPageview']);"</pre>
<p>We&#8217;ve set the custom variable slot to 1, and the scope to the session-level (the last argument, set as 2). If you are already making use of custom variables, be sure to not overwrite a previously occupied slot. For more information on how the custom variable is formatted, see <a rel="nofollow" target="_blank" href="http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html" rel="nofollow" >Google&#8217;s help page</a> on the topic.</p>
<h4>Step 3 &#8211; Create an IF Statement so the CustomVar isn&#8217;t Called Every Time</h4>
<p>We only want to include this line when we have a <em>cd=</em> value, otherwise every new click will overwrite the last value. To do this, I used the following IF statement, again coded in PHP. This is the final step, and the complete Google Analytics snippet:</p>
<pre>&lt;?php if ($rank != '' ) {
echo "&lt;script type=\"text/javascript\"&gt;\n
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
  _gaq.push(['_setCustomVar',1,'Google_Ranking','$rank',2]);
  _gaq.push(['_trackPageview']);";
echo "\n";
  }
else {
echo "&lt;script type=\"text/javascript\"&gt;\n

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-X']);
  _gaq.push(['_trackPageview']);";
    }
echo "\n";
?&gt;

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

&lt;/script&gt;</pre>
<p>Here we&#8217;re checking if <em>$rank</em> has a value. If it does, we&#8217;ll include the custom variable call with that <em>$rank</em> value, if not, we&#8217;ll print the Google Analytics code as normal. Also included in the above are some line breaks (\n), so that the code formats correctly.</p>
<h3>The Most Important Part &#8211; Analyzing Our Data</h3>
<p>What&#8217;s the point of going through all this effort if it doesn&#8217;t provide you with any analytical insight? None, of course. But this rank tracking solution has some added benefits over the traditional rank tracking software that may be really useful to some SEOs. These include:</p>
<h5>Rankings by City, Region, Country</h5>
<p>Traditional rank tracking software suffers in that its ranking results are dependent on the location of the servers. With custom variable rank tracking and a little spreadsheet pivot table magic it&#8217;s pretty easy to get your site&#8217;s rank for any location.</p>
<h5>Historical, Definite, Data</h5>
<p>Once this is properly set up you&#8217;ve got access to definite rankings within your Analytics data from that point on. So as holiday season 2011 rolls around, its easy enough to review where your site ranked during the 2010 holidays, helping to set budgets, goals, and expectations.</p>
<h5>Bounce Rate/eCommerce Data/etc. by Rank</h5>
<p>Whatever your KPI, you can compare it against search ranking. Reporting the ROI of link building efforts or on site optimization becomes much easier when you&#8217;ve got rankings included in your dataset.</p>
<p>Some of the quick ideas I had around this include:</p>
<ul>
<li>Average rank over time for top 50 keywords</li>
<li>Average rank over time for 4+ word keyphrases</li>
<li>Bounce rate for 2nd+ page clicks</li>
<li>Revenue % increase for Keyword X when ranking increases from 2 to 1</li>
</ul>
<p>I should note that getting averages is a lot easier in Excel with a pivot table, as seen below:</p>
<p style="text-align: center;"><img src="http://www.seomoz.org/img/upload/Avg%20Rank.png" alt="Average rank pivot table" width="540" height="201" /><br />
<em>This can also be adjusted to show your minimum rank, as well</em></p>
<h3>Creating Custom Reports and Advanced Segments</h3>
<p>Custom variables aren&#8217;t included in the default reports for Google Analytics, so unless you do all your work in Excel, you&#8217;ll probably want to create some custom reports or advanced segmentation to work with the data directly in Analytics.</p>
<p>Advanced segmentation is great for this data. Below is the function one would use to track rankings between 11 and 15, which might be strong candidates for on-page optimization that could provide the boost onto the first page:</p>
<p style="text-align: center;"><img src="http://www.seomoz.org/img/upload/cd(1).png" alt="Advanced Segmentation" width="400" height="199" /><br />
<em>You can apply this particular advanced segment with <a rel="nofollow" target="_blank" href="http://www.google.com/analytics/reporting/add_segment?share=_iX9XysBAAA.RD_MY1rbVaEf7ayaUJLvVGA5GyS8FBW2gpnvzPGkHsnLD1KsRbpOoN6hgi8uC9PJdVidVhmqk9ZqndZeG-HN5w.9Ffv5XTQzSr8KyoQVNMVeA" rel="nofollow" >this link</a>.</em></p>
<h4>The Downsides</h4>
<p>The most obvious downside is that you&#8217;re only receiving a ranking when a listing is being clicked on, so for very small sites there may be limited utility. Ranking data will be spotty past the 2nd page, as well.</p>
<p>Additionally, the AJAX SERPs are not being served to all users in all locations. Small sample size warning here, but I&#8217;m seeing about 40% of organic Google traffic coming from the AJAX SERPs (done through a simple calculation of visits with our custom variable divided by total Google organic visits over the same time period). Michael Whitaker is seeing this number over 50% <a rel="nofollow" target="_blank" href="http://www.michaelwhitaker.com/blog/2010/09/08/google-ajax-search-results-update/" rel="nofollow" >in his data</a>. This number is likely going to increase as Instant is rolled out further.</p>
<p>The #-pack local listings can really throw things off, too. If a particular query gets one of these to start the SERP, the <em>cd=</em> continues after:</p>
<p style="text-align: center;"><img src="http://www.seomoz.org/img/upload/cd.png" alt="cd= rankings" width="500" height="582" align="middle" /></p>
<p>Lastly, there does exist the possibility that Google discontinues its use of the <em>cd=</em> variable for whatever reason.</p>
<h3>Go Analyze</h3>
<p>I hope some of you can make some good use out of this functionality. I&#8217;ve only had it installed on my sites for a short time, but I&#8217;ve definitely found it interesting to play around with. If you don&#8217;t already have <a rel="nofollow" target="_blank" href="http://excellentanalytics.com/" rel="nofollow" >Excellent Analytics</a> installed in your Excel I would highly recommend doing so, even if you don&#8217;t implement this tracking, and <em>especially</em> if you do.</p>
<p>I&#8217;d like to thank Michael Whitaker of <a rel="nofollow" target="_blank" href="http://monitus.com/" rel="nofollow" >Monitus</a> for his help. He&#8217;s been installing this setup for his clients for a bit now. Monitus offers proper eCommerce Google Analytics installation for Yahoo! stores, which is surprisingly difficult without Monitus.</p>
<p>If you&#8217;ve got any other ideas for working with this data, sound off in the comments or let me know on Twitter <a rel="nofollow" target="_blank" href="http://twitter.com/MikeCP" rel="nofollow" >@MikeCP</a>. Personally, I&#8217;m really excited to have this data rolling in and the possibilities are nearly endless. I&#8217;ll be sure to report any interesting ways to manipulate the data in future blog posts. Cheers!</p>
<p>Do you like this post? <a rel="nofollow" target="_blank" href="http://www.seomoz.org/thumbs/add/blog/11090/1/0" rel="nofollow" >Yes</a> <a rel="nofollow" target="_blank" href="http://www.seomoz.org/thumbs/add/blog/11090/0/0" rel="nofollow" >No</a></p>
<div class="feedflare"><a rel="nofollow" target="_blank" href="http://feeds.feedburner.com/~ff/seomoz?a=XyE68emin-o:PhfI6EeFnWE:yIl2AUoC8zA" rel="nofollow" ><img src="http://feeds.feedburner.com/~ff/seomoz?d=yIl2AUoC8zA" border="0" alt="" /></a> <a rel="nofollow" target="_blank" href="http://feeds.feedburner.com/~ff/seomoz?a=XyE68emin-o:PhfI6EeFnWE:F7zBnMyn0Lo" rel="nofollow" ><img src="http://feeds.feedburner.com/~ff/seomoz?i=XyE68emin-o:PhfI6EeFnWE:F7zBnMyn0Lo" border="0" alt="" /></a> <a rel="nofollow" target="_blank" href="http://feeds.feedburner.com/~ff/seomoz?a=XyE68emin-o:PhfI6EeFnWE:V_sGLiPBpWU" rel="nofollow" ><img src="http://feeds.feedburner.com/~ff/seomoz?i=XyE68emin-o:PhfI6EeFnWE:V_sGLiPBpWU" border="0" alt="" /></a> <a rel="nofollow" target="_blank" href="http://feeds.feedburner.com/~ff/seomoz?a=XyE68emin-o:PhfI6EeFnWE:qj6IDK7rITs" rel="nofollow" ><img src="http://feeds.feedburner.com/~ff/seomoz?d=qj6IDK7rITs" border="0" alt="" /></a> <a rel="nofollow" target="_blank" href="http://feeds.feedburner.com/~ff/seomoz?a=XyE68emin-o:PhfI6EeFnWE:gIN9vFwOqvQ" rel="nofollow" ><img src="http://feeds.feedburner.com/~ff/seomoz?i=XyE68emin-o:PhfI6EeFnWE:gIN9vFwOqvQ" border="0" alt="" /></a></div>
<p><img src="http://feeds.feedburner.com/~r/seomoz/~4/XyE68emin-o" alt="" width="1" height="1" /></p>

<p class="syndicated-attribution">Read other posts by this Author: <a href="http://www.iwanttoknowif.com/author/mikecp/" title="Read other posts by MikeCP">MikeCP</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.iwanttoknowif.com/turn-google-analytics-rank-tracker-custom-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

