Created
February 25, 2013 19:00
-
-
Save hermpheus/5032295 to your computer and use it in GitHub Desktop.
GA: Rank Tracking Based on User visits
This file contains hidden or 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
<script type="text/javascript"> | |
if (document.referrer.match(/google.com/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]); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment