How to Track Keyword Ranking using Google Analytics

A few days back, I had shared a gem of JavaScript code through which one could track the performance of content through Google Analytics. If you haven’t implemented it, I’d advise you to do it as soon as possible. Here’s another handy code to track keyword ranking using Google Analytics.

Here’s the link to advanced content tracking through Google Analytics.

Yet another way to track how your content is performing (albeit not directly) is this yet another JavaScript code through which you could track keyword ranking using Google Analytics. It tells you about your health in search engine ranking performance and to check whether you are creating quality content.

Through this event tracking code you could actually measure value that is being added through your content marketing program.

If you’re not getting valuable traffic from content and keywords that you are optimizing for then you need to re-evaluate your tactics and change.

As opposed to Google Webmaster Tools wherein you get both impression and CTR, through this mode of rank tracking, you only get the data actually coming to your site through clicks.

The advantage of this approach over Google WMT is that it does not give you the ranking for search terms if you are not getting traffic. You al

What makes this approach interesting is the fact that If you are not getting traffic and/or conversions then your ranking sucks. It’s time for you to recheck and revamp your content marketing strategy.

The code is relatively simple. All it does is looks at the referring URL and, if it’s from Google Organic, plucks out the location of the search result and sends it to Google Analytics using an Event.

Here’s the code – feel free to copy it and use it. You do not need to customize the code for your site.

<!– Google Analytics Rank Tracking Script –>

<script type=”text/javascript”>

if (document.referrer.match(/google.([a-zA-Z]{2,5})/gi) && document.referrer.match(/cd/gi)) {
var myString = document.referrer;
var r = myString.match(/cd=(.*?)&/);
var rank = parseInt(r[1]);
var kw = myString.match(/q=(.*?)&/);
if (kw[1].length > 0) {
var keyWord = decodeURI(kw[1]);
} else {
keyWord = “(not provided)”;

var p = document.location.pathname;
_gaq.push([‘_trackEvent’, ‘RankTracker’, keyWord, p, rank, true]);
<!– Google Analytics Rank Tracking Script Ends –>

Keep in mind that this script relies on Google Analytics Event Tracking which I hope you are aware of. If you don’t know how Event Tracking works in Google Analytics then do check out this tutorial on Event Tracking in Google Analytics.

In this Rank Tracking technique in Google Analytics, the following information would be sent to your ga.js data with the event:

Category: RankTracker

All of the data will be grouped under the Event named RankTracker.

Action: keyword

The action will collect the search term the user entered on Google.

Label: landing page

The label will be the landing page that the user landed on.

Value: Google Search Rank

Rank of the search result will be collected for each keyword.

Non-interactive: TRUE

This event will NOT change your bounce rate calculations.

So enjoy! And let me know if you think of any modification.

Credit to AJ Kohn and Justin Cutroni

(Visited 195 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *