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…
- Copy app/code/core/GoogleAnalytics/Block/Ga.php
to app/code/local/Mage/GoogleAnalytics/Block/Ga.php - Open app/code/local/Mage/GoogleAnalytics/Block/Ga.php
- On Line 122, Find:
Mage::app()->getStore()->getFrontendName()
- Replace With:
$this->jsQuoteEscape(Mage::app()->getStore()->getFrontendName())
- Save the file and test.
This basically escapes any quotes that may be included in your Magento store name.