ga.js and not urchin.js, because it's way more hip. If you need to use urchin.js, it should be similar to this but there will be a few things you'll have to change.yourdomain.tld, www.yourdomain.tld, secure.yourdomain.tld) you'll need to change your tracking code slightly: http://www.google.com/support/googleanalytics/bin/answer.py?answer=55532<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"> var pageTracker = _gat._getTracker("UA-XXXXXXX-1"); pageTracker._setDomainName("YOURDOMAIN.TLD"); pageTracker._initData(); pageTracker._trackPageview(); </script>
PHPSESSID,fc_PHPSESSID to the “Exclude URL Query Parameters” in your analytics settings. Detailsindex.html or index.php or etc. Make sure you understand what this means, as it affects stuff like yourdomain.com/ as well as yourdomain.com/dir/sub/./receipt/cart for the URL and “Cart” for the Name./checkout for the URL and “Checkout” for the Name.pageTracker._trackPageview(); to pageTracker._trackPageview(”/cart”);<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"> var pageTracker = _gat._getTracker("UA-3634691-1"); pageTracker._setDomainName("YOURDOMAIN.COM"); pageTracker._setAllowAnchor(true); // Workaround for FoxyCart's "FoxyBox" (Thickbox) function fc_cart_init() { pageTracker._initData(); pageTracker._trackPageview("/cart"); } setTimeout( fc_cart_init , 2000 ); // end workaround </script>
Workaround comments, which delays the Google Analytics slightly. The 2000 is 2000 milliseconds (2 seconds). You could probably change the 2000 to 1000 or 1500 if you're concerned that people might close the cart before that time. However, if you set it too low it will error and Google Analytics won't record the page view.pageTracker._trackPageview(); to pageTracker._trackPageview(”/checkout”);pageTracker._trackPageview(); to pageTracker._trackPageview(”/receipt”);^^analytics_google_ga^^. This generates code that tracks the sale, is what actually tracks the ecommerce transaction. (If you're using urchin.js, use ^^analytics_google_urchin^^.)<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"> var pageTracker = _gat._getTracker("UA-XXXXXXX-1"); pageTracker._setDomainName("YOURDOMAIN.com"); pageTracker._initData(); pageTracker._trackPageview("/receipt"); </script> ^^analytics_google_ga^^ </body> </html>
The ^^analytics_google_ga^^ will output the cart array, as described here. GA will pick up on this automatically.