Created
February 10, 2013 08:57
-
-
Save yoavmatchulsky/4748920 to your computer and use it in GitHub Desktop.
RankTracker based on http://cutroni.com/blog/2013/01/14/a-new-method-to-track-keyword-ranking-using-google-analytics/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(doc) { | |
var ref = doc.referrer; | |
if (ref.match(/google\./gi)) { | |
var query = ref.split('?')[1], | |
keyword = '(not provided)', | |
pathname = doc.location.pathname, | |
rank = null, | |
param; | |
if (query) { | |
params = query.split('&'); | |
for (var i in params) { | |
if (params.hasOwnProperty(i)) { | |
param = params[i]; | |
if (param.indexOf('cd=') == 0) { | |
rank = parseInt(param.substring(3)); | |
} | |
else if (param.indexOf('q=') == 0) { | |
keyword = decodeURI(param.substring(2)); | |
} | |
} | |
} | |
} | |
_gaq.push(['_trackEvent', 'RankTracker', keyword, pathname, rank, true]); | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment