Functions:googleTrack

From Whirlwind eCommerce Wiki
Revision as of 14:34, 29 May 2009 by Root (Talk | contribs)

Jump to: navigation, search

Description

eV::googleTrack() returns tracking code for google analytics. If used, echo the returned value before the </body> tag.

Syntax

$string = eV::googleTrack($trackerCode);

Paramaters

  • $trackerCode STRING
The unique tracking id assigned by Google to track your site. Will be in the format "UA-1234567-1".

Return Values

Returns a String containing the complete javascript, including the <script> and </script> bounding tags. Example of returned value is below:

<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
	try {
	var pageTracker = _gat._getTracker("UA-1234567-1");
	pageTracker._trackPageview();
	} catch(err) {}
</script>

Example

echo "<html>";
 
echo "<head>";
echo "<title>$metaTitle</title>";
echo "</head>";
 
echo "<body>";
echo $copy;
// display googleTrack code
echo eV::googleTrack('UA-1234567-1');
 
echo "</body>";
echo "</html>";


See Also