• Resolved bergeny

    (@bergeny)


    Hello,
    I wonder if that’s a bug whic is not detected yet as I searched all the web but in vain.

    dataLayer on gtm4wp.changeDetailViewEEC returns undefined value for currencyCode ,name ,category and stocklevel.

    {
     event: 'gtm4wp.changeDetailViewEEC',
     ?ecommerce: {
     ? ?currencyCode: undefined,
     ? ?detail: {
     ? ? ?products: [
     ? ? ?  {
     ? ? ? ? ?name: undefined,
     ? ? ? ? ?id: 18771,
     ? ? ? ? ?price: 15,
     ? ? ? ? ?category: undefined,
     ? ? ? ? ?stocklevel: undefined,
     ? ? ? ? ?variant: 'brown-hamster'
     ? ? ?  }
     ? ?  ]
     ?  }
      },
     ?ecomm_prodid: '18771',
     ?ecomm_pagetype: 'product',
     ?ecomm_totalvalue: 15,
     ?gtm.uniqueEventId: 6122}

    A part of js code that contains the variables in the above dataLayer is located in gtm4wp-woocommerce-enhanced.js and is as follows:

            var _product_form = jQuery(this).closest('form.cart');
            var _product_var_id = jQuery('[name=variation_id]', _product_form);
            var _product_id = jQuery('[name=gtm4wp_id]', _product_form).val();
            var _product_name = jQuery('[name=gtm4wp_name]', _product_form).val();
            var _product_sku = jQuery('[name=gtm4wp_sku]', _product_form).val();
            var _product_category = jQuery('[name=gtm4wp_category]', _product_form).val();
            var _product_price = jQuery('[name=gtm4wp_price]', _product_form).val();
            var _product_currency = jQuery('[name=gtm4wp_currency]', _product_form).val();
            var _product_stocklevel = jQuery('[name=gtm4wp_stocklevel]', _product_form).val();
    
                window[gtm4wp_datalayer_name].push({
                    'event': 'gtm4wp.addProductToCartEEC',
                    'ecommerce': {
                        'currencyCode': _product_currency,
                        'add': {
                            'products': [{
                                'id': gtm4wp_use_sku_instead ? _product_sku : _product_id,
                                'name': _product_name,
                                'price': _product_price,
                                'category': _product_category,
                                'quantity': jQuery('form.cart:first input[name=quantity]').val(),
                                'stocklevel': _product_stocklevel
                            }]
                        }
                    }
                });

    After I tried to debug that issue I figured out that the HTML variation form in my frontend doesn’t contain the gtm4wp_ data.

    Any solution for that please ?

    • This topic was modified 6 years, 1 month ago by bergeny.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bergeny

    (@bergeny)

    Hello again
    I finally figured out that the hook ‘woocommerce_after_add_to_cart_button’ is missing and it’s the theme developer fault, everything is going as expected after I manually added the hook

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Great to hear that, let me know if you need anything else!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No Data-gtm4wp… in variation form !!’ is closed to new replies.