Google Analytics doesn’t track Magento’s E-Commerce Data

I encountered an issue where Google Analytics wasn’t receiving the ecommerce data it normally receives when a user places an order.

The issue is related to a small oversight by Magento developers, in the core GoogleAnalytics extension included with Magento.

If you have any quotes in your Magento’s store name, the Tracking Code will fail.  This is due to the quotes not being escaped in the javascript for the Analytics code.

To fix this issue, do the following…

  1. Copy app/code/core/GoogleAnalytics/Block/Ga.php
    to app/code/local/Mage/GoogleAnalytics/Block/Ga.php
  2. Open app/code/local/Mage/GoogleAnalytics/Block/Ga.php
  3. On Line 122, Find: Mage::app()->getStore()->getFrontendName()
  4. Replace With: $this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName())
  5. Save the file and test.

This basically escapes any quotes that may be included in your Magento store name.

Leave a Reply