Difference between revisions of "Functions:googleTrack"
From Whirlwind eCommerce Wiki
(New page: == Description == eV::googleTrack() returns tracking code for google analytics. If used, echo the returned value before the </body> tag. == Syntax == $string = eV::googleTrack($trac...) |
(No difference)
|
Revision as of 14:22, 29 May 2009
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> <head> <title>My PageTitle</title> </head> <body> My body content "; echo eV::googleTrack('UA-1234567-1'); echo "</body></html>";