/* 
The following function pulls the ranking
from the cd parameter in Google and pushes it
to a custom variable in Google Analytics
called "Rankings." 

*/

function rankingsPush()
{
  var url = String(document.referrer);

// confirm they came from G
	if (url.indexOf ("google.com") !=-1)
	{	

		var urlVars = {};
		var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value)
		{
			urlVars[key] = value;
		});

		// Push to GA Custom Variables
		_gaq.push(['_setCustomVar', '1', 'Posicion SERP', urlVars["cd"], 1]);

	} else if (url.indexOf ("google.es") !=-1)
	{	

		var urlVars = {};
		var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value)
		{
			urlVars[key] = value;
		});

		// Push to GA Custom Variables
		_gaq.push(['_setCustomVar', '1', 'Posicion SERP', urlVars["cd"], 1]);

	}

}

