Ecommerce (Woocommerce) tracking setup help needed

Hi,
Sorry for the newbie question but I’m really struggling here with the e-commerce tracking setup. We are using Wordpress/Woocommerce and at the moment I have added these tags to my site (e-commerce cart update and e-commerce order confirmation) that are shown in the docs.

Cart update tag is this:

<script>
      var _paq = _paq || [];
      var cart_amount = {{ cart_amount }};
      var products = {{ products }};
      products.forEach(function(product){
        _paq.push(["addEcommerceItem",product.sku, product.name,product.category, product.price, product.quantity])
      });
      _paq.push(["trackEcommerceCartUpdate",cart_amount]);  
    </script>

Order confirmation tag is this:

<script>
     var _paq = _paq || [];
     var products = {{ products }};
     products.forEach(function(product){
       _paq.push(["addEcommerceItem",product.sku, product.name,product.category, product.price, product.quantity])
   });
     _paq.push(["trackEcommerceOrder",{{ order_id }}, {{ grand_total }}, {{ subtotal }}, {{ tax }}, {{ shipping }}, {{ discount }}]);
   </script>

If I run tag debugger then it shows that tags are loaded on my site, but it seems that it doesn’t track anything.

Please advise what is it I’m doing wrong here or what should I do in order to make tracking work.

Thanks,
J.

I’d suggest double checking if the field types are correct. Docs are available here. For instance, product.sku and order_id have to be strings. Some code examples are also available here. Also, do you see any errors in browser’s console?

Hi,

Thank you for your answer.

Unfortunately I’m not good at programming or JavaScript, and therefore I have no knowledge about how to add those fields as strings :slight_smile:
I tried to hire someone from Fiverr but got no offers. Although, everyone offered my “I can make Google Analytics ecommerce tracking to work.”

If you have time you can take a look at my test site here. It has these tags and tracking added.

Currently, console displays this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
    at <anonymous>:4:15
    at Object.i [as appendChild] (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:8:16850)
    at a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:827
    at Object.forEach (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:8:25107)
    at u (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:797)
    at Object.render (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:1404)
    at n.render (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:76)
    at Object.handle (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:2371)
    at r (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:2928)
    at Object.handle (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:3469)
VM78:5 Uncaught TypeError: Cannot read properties of undefined (reading 'forEach')
    at <anonymous>:5:16
    at Object.i [as appendChild] (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:8:16850)
    at a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:827
    at Object.forEach (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:8:25107)
    at u (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:797)
    at Object.render (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:1404)
    at n.render (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:76)
    at Object.handle (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:2371)
    at r (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:2928)
    at Object.handle (a2a75c35-23ed-49bc-b12d-5161b7e977d5.js:11:3469)

It will be hard to set it up without at least some JavaScript knowledge. As you can see in the code, to make it work, you need to define the variables that contain the product data. Your setup is missing this part. Going through the entire setup for Woocommerce isn’t something that can be solved via forums thread.

As a side note, I’ve heard that one of our partners is considering creating Woocommerce plugin that would do all the work for you.

Thanks. Do you know anyone who I could hire for this gig?

As a side note, I’ve heard that one of our partners is considering creating Woocommerce plugin that would do all the work for you.

It would be great and would help a lot. Any ETA of this is not known yet?

As a small update, we’ve discussed this matter internally and will be working on the woocommerce plugin soon. Still, it might take some time until it’s released.

Thank you for the update.