Issue with Ecommerce Data Collecting(Cart Update)

Hi,

I have an issue with the data in my Cart Update tag not being sent in the right order.

This is how an example of how our datalayer is set up ( Because we don’t have any product category to fill we data, we haven’t added that to the data layer though we have understood that it is optional data? ):

window.dataLayer.push({
  event: 'cart_update',
  products: [{
    sku: '123456',
    name: 'XXXXXXXX',
    price: 1234,
    quantity: 1,
  },
    {
      sku: '23456',
      name: 'XXXXXX',
      price: 2345,
      quantity: 1,
    },
  ],
  cart_amount: 3579,
});

And this is what our Cart Update Tag looks like( when it’s not able to send data ):

<script>
(function () {

  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>

But when we remove product.category from the Cart Update Tag, it does send data that we can see in the Tracker Debugger, but it’s in the wrong order.

For some reason I can’t attach images to this topic so I will have to write it. It looks like this in the Tracker Debugger:

Item SKU: 1232354231
Item name: Example Product
Item category: 151,56 (This is the actual price of the product)
Item price: 1,00 € (This is the actual quantity)
Item quantity: 1 (This is getting added somehow that we don’t know)

Is there some way we can fill the Item category field without having to add it to the datalayer? Like null, undefined, or something else?

Hi @Dataguy,
let me take it with respective team, I’ll get back to you.
Tymek

1 Like

The code of the Cart Update tag is correct here. If you won’t provide the category in the data sent to datalayer, then category value sent in that case will be undefined which is acceptable value.

If you’re asking if you can remove the product.category parameter from your tag, then it’s possible but you’ll have to in it’s place send another value. It can be hardcoded value (e.g. empty string), but the addEcommerceItem command requires all parameters if you want to sent the last parameter even if category should be skipped like in this case.

The reason why you see this:

Item quantity: 1 (This is getting added somehow that we don’t know)

is because default value for item quantity optional parameter is equal to 1.

I would suggest to keep your current working Cart Update tag, or changed it this way if you want to remove undefined product.category reference from it:

<script>
(function () {

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

 })();
 </script>

Hi @Roman_Sek ,

We have tried to replace product.category with a hardcoded value like an empty string with no success, sadly.

The suggestion you provided(below) we have already tried with several other variants of it. We tried to replace with "", null, undefined, [ ], { } and even place product.name to see if it would just be possible to get some data into the Ecommerce reports. But maybe we have missed something?

@Piotrek Do you have any thoughts on this?

<script>
(function () {

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

 })();
 </script>

@Dataguy do you have a website where we could see the code live in action?
If you don’t want to share a link publicly, you can send it to me or @Roman_Sek via private message.

1 Like

Hi @Piotrek ,

Don’t know if this is in your backlog or it has been forgotten, but have you had the time to look at this yet?

I have sent you the link to our website in a private message, should be among your PM´s.

Thanks in advance!