Search This Blog

Aug 3, 2011

Fixed Google Analytics and GoogleAnalyticsplus issue for Magento 1.5

Recently, I installed GoogleAnalyticsplus extension in tracking conversions funnels of their ecommerce transactions, one of my client sites. The said extension is great in handling data however there are minor issues in Magento CE 1.5. One of these issues is that Google Analytics is not tracking properly when you were using Google API at System Configuration.

Why it isn’t tracking?

Google Analytics is set up on System-> Configuration->Sales->Google API -> Google Analytics. Then, it is loaded the tracking script on your site automatically. The script is either place before head tag or in body tag.

However, once you installed GoogleAnalyticsPlus extension, GA script is omitted and replaced by GoogleAnalyticsPlus generated script bywhich exactly the same script, though Google Account ID is not passed. The reason behind it is because classes that extension used is already deprecated Magento 1.5

Example of class that GoogleAnalytics plus called:

app/code/core/Mage/GoogleAnalytics/Block/Ga.php:

/**
     * @deprecated after 1.4.1.1
     * @see _toHtml()
     * @return string
     */
    public function getAccount()
    {
        return '';
    }

app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ga.php on line 93. $this->getAccount() is still called the above class. This deprecated function is used to retrieve the Google Account ID.

gaq.push(["_setAccount", "' . $this->getAccount() . '"], ["_trackPageview","'.$this->getPageName().'"]);';

Solution:


You can either replace the deprecated function or to used the new getTrackingCode function.

Warning: Please make sure that you make a copy on local folder.

Directory should name like this.

app/code/local/Mage/GoogleAnalytics/Block/Ga.php

Old function:

/**
     * @deprecated after 1.4.1.1
     * @see _toHtml()
     * @return string
     */
    public function getAccount()
    {
        return '';
    }


Replace by:
public function getAccount()
    {
      $accountId = Mage::getStoreConfig(Mage_GoogleAnalytics_Helper_Data::XML_PATH_ACCOUNT);
        return $accountId;
    }

Save the file in your local folder, clear cache and reload your page. At the end of the day, you’ll start receiving data on analytics.

Please post a comment if you encounter further trouble.

1 comments:

Darwis Symonds said...

Searching for  Bankruptcy
Discharge
papers? Get official bankruptcy discharge papers  $9.99 online. Fast Delivery by email same
day within 1 - 6 hours.