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!

Hi @Piotrek ,

Guess this one might have fallen between the chairs, hope you have time to answer this one :slight_smile:

Now we have added product.category within the cart_update data layer that is a static string named “All”.

The data layer looks like this:
Capture55

I applied your recommended dedicated custom tag for Ecommerce cart update accoring to your Ecommerce Tracking guide that is shown among the solution templates:

I used Omnibug in DevTools on chrome to capture how it would look like:

This looked correct at first sight and I got very happy, but I still didn’t see any Cart Update event in the Tracker Debugger and we don’t get any data into the reports.

One interesting thing though was that I found this Broken Event appearing in the Tracker Debugger:

Is the reason we don’t get it to work connected to this Broken Event? If so, what would we need to change? If not, what could we debug to find the problem and fix it?

Would really appreciate some feedback on this or a solution. Thanks!

Hey @Dataguy, sorry that preparing an answer is taking so long.

We were reviewing our ecommerce tracking internally - we plan to implement multiple improvements and bug fixes. One of our developers - @Roman_Sek will get back with an answer in this thread :slightly_smiling_face:

1 Like

I had a thought while looking at our data layer and the Piwik Dev documentation.

Could it be that the number/integer in the Product Price field needs to be a number with a dot ( . ) instead of a comma ( , )? And that’s why the data in the tag can’t be handled and collected in Piwik Pro?

For example, instead of “186,98” it needs to be “186.98”?

I’m no developer so maybe I am totally wrong but worth asking.

Yes, JavaScript is using the dot in decimal numbers instead of comma. Please change it to “186.98" and it should work.

1 Like

To be more precise, the number that is expected in the productPrice parameter should be sent in cents (in this case: “18698”). We use that convention to avoid any rounding errors caused by the JavaScript. Let me know if it will help.

1 Like

Hi @Roman_Sek ,

I have a following question for the price-data parameter for the Ecom V2 events. We have set up new data layers events for each separate event, but we get a bit confused though as I understand on you comments earlier in this thread: “186.98”(In Euros) and “18698”(In Cents) both work?

So for example, if we have a product that costs 12 650 432,50€, should the price-event parameter in the data layer objects be populated as one of the alternatives below? Or is one of them preferred for best practice?

Alternative 1: “12650432.50”
Alternative 2: “1265043250”

And also to double-check, when we use integers/numbers in the event parameters in the data layer events, should they always in all cases use dot(.) in decimal numbers? Is there possibly some documentation regarding this in the Dev documentation?