Search Descriptions Version
 
 
This article applies to: ML8

Google Analytics and eCommerce Tracking


The storefront software allows store admins to easily integrate with Google's Analytics service. These features help you "find out what keywords attract your most desirable prospects, what advertising copy pulled the most responses, and what landing pages and content make the most money for you." (from Google's site. See their feature page for more information).

Setup

There are basically 3 parts to the integration with Google's tracking tools:

- ga.js script - This is a JS snippet inserted into your template file, which gives your site access to Google's JS functions
- Analytics - This is the core Analytics functionality, which tracks page hits, page referrals, conversions (if configured to), etc
- Conversion Tracking - This function tracks only conversions, as defined in your Google account (in this case, completed sales)


ga.js script

Insert the following code into your template.ascx file before the </head> tag. This code will be inserted into the top of every page on your site that inherits the storefront skin, allowing each page to use Google's Analytics functions.

<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>


Analytics

There are 2 steps to adding ecommerce tracking to your site:

1 - Add the (!GOOGLE_ECOM_TRACKING_V2!) skin token just before the </body> tag in your template.ascx page.
2 - Set the Google.AnalyticsAccount to your Google Analytics account ID (in the format of UA-XXXXXXX-X). This ID is obtained from Google.

This will insert code similar to what is shown below into each page EXCEPT orderconfirmation.aspx (by default, see below for more info) to report page hits to Google. This information can be used for tracking ad campaign success, where customers abandon your site, etc. See here for more details on how to use this information.

<script type="text/javascript">

var pageTracker = _gat._getTracker("UA-XXXXXXX-X");

pageTracker._initData();

pageTracker._trackPageview();

</script>

eCommerce Tracking

Conversions, in the case of an ecommerce store, are completed sales. These are tracked by inserting special JS code into orderconfirmation.aspx - which customers will only see after finalizing their purchases. The steps in the Analytics section above will insert tracking code on every page except that orderconfirmation page. This means that while the basic Analytics tools show you page views, abandons, etc, they do not track full conversions. To do that, simply set the Google.EcomOrderTrackingEnabled AppConfig to true.

In order to see the ecommerce data in google analytics you will also need to make sure your site is setup as an ecommerce site in your google analytics account.

Notes

- These features will only function with the storefront is in live mode (UseLiveTransactions AppConfig).
- Analytics and conversion results can take up to 24 hours after setup to begin appearing in your Google account.
- If you have enabled the Analytics conversion tracking (Google.EcomOrderTrackingEnabled) and standard conversion tracking, the numbers reported by those 2 features should be identical. If they vary, something is not configured properly.
- Google's Ecommerce Tracking will not always work reliably for PayPal and PayPal Express transactions due to their lack of an API. Since the feature relies on javascript being executed on a page, and PayPal customers will not always actually hit a finally page on your site (due to browser issues, redirects, IPN, etc), ecommerce tracking cannot track all PayPal orders.
- Google's Ecommerce Tracking will not work for Google Checkout since that checkout method does not return to the OrderConfirmation.aspx page.

Google Analytics and off-site payment methods such as PayPal

When using PayPal or other off-site payment methods the customer's original referral source can get overwritten, skewing the results. Please review this article to determine how to best handle this scenario.