Support » Plugin: Enhanced Ecommerce Google Analytics Plugin for WooCommerce » Product Category shows Variation Attributes (for Variable Products)

  • Resolved amitramani

    (@amitramani)


    What I have observed is that for Variable Products, the “Product Category (enhanced e-commerce)” field in Google Analytics always shows Attributes instead of the Product Category. This happens only for variable products.

    For simple products, it shows the Product Category correctly. Has anyone else noticed this?

    Looking at the code, it appears that for variable products, the code is picking up attributes instead of category:

                    if (isset($_product->variation_data)) {
                        $categories=esc_js(wc_get_formatted_variation($_product->get_variation_attributes(), true));
                    } else {
                        $out = array();
                        if(version_compare($woocommerce->version, "2.7", "<")){
                            $categories = get_the_terms($_product->ID, "product_cat");
                        }else{
                            $categories = get_the_terms($_product->get_id(), "product_cat");
                        }
    
                        if ($categories) {
                            foreach ($categories as $category) {
                                $out[] = $category->name;
                            }
                        }
                        $categories=esc_js(join(",", $out));
                    }

    Any ideas?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tatvic

    (@tatvic)

    Hi @amitramani,

    Thanks for posting us.

    We would fix the reported issue in the next release of the plugin so that it would pick up the category instead of attributes for variable products.

    We hope this helps.

    Regards,
    Tatvic Analytics.

    Plugin Author Tatvic

    (@tatvic)

    Hi @amitramani,

    We are closing this thread as we would include the fix in the upcoming release of the free version.

    Regards,
    Tatvic Analytics.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Product Category shows Variation Attributes (for Variable Products)’ is closed to new replies.