fooman / googleanalyticsplus

Magento Extension to add extra features to the default GoogleAnalytics module.
http://store.fooman.co.nz/extensions/magento-extension-googleanalyticsplus.html
100 stars 53 forks source link

Store code is missing in the pageview/pagename url #79

Closed hostep closed 8 years ago

hostep commented 9 years ago

Hi

On most of our Magento webshops we have enabled the setting 'Add Store Code to Urls' (System => Conf => Web). So we can have different storeviews on http://domainname.com/en/, http://domainname.com/nl/, http://domainname.com/fr/, ...

But we just noticed this store code isn't added to the url in the pageview param in the universal analytics code.

I think you can solve it by changing the code in Fooman_GoogleAnalyticsPlus_Block_Common_Abstract::getPageName to:

$url = Mage::getSingleton('core/url')->escape(
    rtrim(
        str_replace(
            'index/', '',
            Mage::app()->getRequest()->getBaseUrl() .
            (Mage::getStoreConfigFlag('web/url/use_store') ? '/' . Mage::app()->getStore()->getCode() : '') . // <= add store code to the url if enabled
            Mage::app()->getRequest()->getRequestString()
        ), '/'
    ). $query
);

I haven't tested this very thoroughly though.

The getBasePageName method might need an update too, but I haven't checked out what it is used for yet.

What do you think?

Thanks!

fooman commented 9 years ago

Thanks for the feedback - getBasePageName would also need to be amended as it's used during checkout.

geo782 commented 8 years ago

Hi, Is this fixed in latest version or do we have to change code?

Thanks George

hostep commented 8 years ago

Hi @geo782

I created a pull request which isn't merged into master yet, you can manually merge this on top of the code you have checked out.

PR: https://github.com/fooman/googleanalyticsplus/pull/81

@fooman: can this get merged in master, or is there something wrong with the PR which I should fix?