Archive for December, 2012

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.

Magento does some excessive logging to track customers. This in return causes your Magento database to expand exponentially in size, and inevitably decreases your sites overall performance.

I found that disabling logging from the Magento admin does not stop Magento from writing to the log tables in the database. To tell Magento to completely stop, do the following.

1. Open your app/etc/local.xml file
2. Paste in the following, right before the </config> closing tag:

<frontend>
    <events>
        <controller_action_predispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_predispatch>
        <controller_action_postdispatch>
            <observers><log><type>disabled</type></log></observers>
        </controller_action_postdispatch>
        <customer_login>
            <observers><log><type>disabled</type></log></observers>
        </customer_login>
        <customer_logout>
            <observers><log><type>disabled</type></log></observers>
        </customer_logout>
        <sales_quote_save_after>
            <observers><log><type>disabled</type></log></observers>
        </sales_quote_save_after>
        <checkout_quote_destroy>
            <observers><log><type>disabled</type></log></observers>
        </checkout_quote_destroy>
    </events>
</frontend>

3. Save your local.xml file

4. Now to go System > Configuration > Advanced and set Mage_Log to Disable

5. Finally, flush your Magento caches under System > Cache Management

Magento should no longer write logs to these tables.

To clean out your existing log tables, just run the following SQL command against your Magento database.

WARNING: Once you truncate these tables, the log information will be permanently lost. If you have no need for this log data, then by all means get rid of it!

TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_event;