Americart Support
posted this on September 05, 2012 18:23
Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website. To enable it to track visits to your webpages, you must add the Javascript code provided by Google to your webpages' source.
After adding the code to your website, you will not immediately see results in your Google Analytics statistics, because their reports are only updated every 24 hours.
Google's most recent script is called the Asynchronous Tracking Script. While they still support tracking from the Traditional script, it is not recommended.
The asynchronous snippet works differently from the traditional script. The asynchronous script is loaded simultaneously with the page content and doesn't need to be placed in the footer. Google recommends that the asynchronous script be placed as the very last script before the </head> tag.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-x']);
_gaq.push(['_trackPageview']);
##GOOGLECONVERSIONTRACKINGASYNC##
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Of course for either script replace the text xxxxxx-x with your Google Analytics account number
This section of the KB is only for legacy purposes. Google strongly recommends using the newer Asynchronous Script as it is more accurate and faster.
If you still wish to use the Traditional script, it needs to be placed in the footer under Themes > [Active Theme] > Page Footer.
To use this script add a Custom HTML Snap-In to the page and paste the script into it. Be sure the Snap-In is set to HTML mode and not WYSIWYG mode.
Note: this only works with dedicated SSL, not shared SSL.
<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-xxxxxx-x");
pageTracker._trackPageview();
##GOOGLECONVERSIONTRACKING##
} catch(err) {}
</script>
##ADDITEM##
Output sample: pageTracker._addItem( "100075","eProduct3","eProduct3","","0.00","2");
The merge code below will create a line item for the Google Asynchronous tracking:
##ADDITEMASYNC##
Output sample:_gaq.push(['_addItem', '100075','eProduct2','eProduct2','','0.00','1']);
Comments
How do you install the Google Analytics script for eccomerce tracking?