How to install Google Analytics (beta) and E-commerce functionality?
1. create a new directory 'analytics' in catalog/includes/modules/.
result: catalog/includes/modules/analytics/.
2. copy the file 'analytics.php' into this directory.
if necessary, change the $transaction_string and/or the $item_string , for example
if you do not use the value customers_state or affiliation tag, replace this with dummy text (company name description), like:
$transaction_string = '"' . $order_id . '"," ' . $analytics_affiliation . '",
"' . $analytics_total . '","' . $analytics_tax . '","' . $analytics_shipping . '",
"' . $orders['customers_city'] . '","DUMMYTEXT","' . $orders['customers_country'] . '"';
3. make a copy of your original footer.php in the directory catalog/includes/, rename this file to footer-tracker.php.
4. The original contribution placed the Analytics tracking code in the header. A more convient way to place the tracker code, is at the end of the source code.
Therefor: in the ORIGINAL footer.php place the following script at the end of the file
<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-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
5. Replace the xxxxxxx-x in the script above with your personal Analytics UA-code (available in your Google Analytics account).
6. open/edit catalog/checkout_success.php.
7. Underneath <link rel="stylesheet" type="text/css" href="style.css"> paste the following code:
<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-x");
pageTracker._initData();
pageTracker._trackPageview();
<?php
include(DIR_WS_MODULES . 'analytics/analytics.php');
?>
</script>
8. Again (as in step 4), replace the xxxxxxx-x in the script above with your personal Analytics UA-code.
9. At the bottom of the file checkout_success.php change the following line:
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
into
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer-tracker.php'); ?>
<!-- footer_eof //-->
10. Save the checkout_success.php
Every successful transaction made in your store is now trackable in Google Analytics. Navigate to the e-commerce overview: dashboard -> e-commerce
Q: There is no button "e-commerce" in my Analytics menu
A: E-commerce tracking is not enabled for your website. You can enable this in the profile settings of "Main Website Profile Information". Enable "Yes, an E-Commerce Site" to track your transactions.
Q: Is it necessary to update from Urchin to the new Beta code?
A: To be ahead of mandatory updates, yes. Google announced that the old Analytics Urchin tracking would be supported for at least 12 months.
Bookmarks