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

Category Tracking Attribute in GoogleAnalyticsPlus #89

Closed geo782 closed 8 years ago

geo782 commented 8 years ago

Hi, I have to set the category name in Category Tracking Attribute. If i leave this empty and check source code of product page it has : /* <![CDATA[ _/ var google_tag_params = { ecomm_prodid: '3610dk', ecomm_pagetype: 'product', ecomm_pvalue: 67.15, ecomm_category: 'Default Category', ecommtotalvalue: 67.15 }; / ]]> */ The "Default Category" is the root category, not the last subcategory.

If I choose category_ids, then it shows ecomm_category: 'Array'.

What do i have to do to get the correct category name?

Regards George

fooman commented 8 years ago

Choosing category_ids in the product attribute would not work as you have found out. I'd suggest using the default and then edit this line https://github.com/fooman/googleanalyticsplus/blob/v0.16.9/app/code/community/Fooman/GoogleAnalyticsPlus/Block/Common/Abstract.php#L65 to something like

            if ($category && $category->getName() != 'Default Category') {

Default Category