Tuesday, 1 October 2013

pulling custom rankings in Google Analytics

pulling custom rankings in Google Analytics

can someone explain this script to me. It is supposed to pull specific
rankings in Google however, i am unsure how this replace function is
working. What does "m," "key," and "value" come from?
Basically what I don't understand is how the ranking data is being
collected from this script.
function rankingsPush()
{
var url = String(document.referrer);
// confirm they came from G
if (url.indexOf ("google.") !=-1)
{
var urlVars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value)
{
urlVars[key] = value;
});
// Push to GA Custom Variables
_gaq.push(['_setCustomVar', '1', 'Rankings', urlVars["cd"], 2]);
// Return the ranking in case
// you dynamic targeting based on ranking
return urlVars["cd"];
}
}

No comments:

Post a Comment