Cart updates (add, remove, clear)

Hi, I need a bit of clarification about the cart operations. I hope someone can help.

As I understand it, Piwik Pro requires the entire cart content to be available whenever a cart update is made. For example, I have a product in my cart and I’m going to add another product now on another page. I need to push both items with the trackEcommerceCartUpdate event (with all their info like sku, name, category etc) when I’m adding the second one.

So, essentially I’m telling Piwik Pro what I currently have, not what changed. Is this explanation correct?

How about removing from cart? Let’s say two different items in my cart (3 of sku-123 and 4 of sku-456) and I want remove sku-123. I first run this:
_paq.push(["removeEcommerceItem", "sku-123"]);

and then this:
_paq.push(["trackEcommerceCartUpdate", 120]); (with the total value of the items remaning in the cart)

Don’t I need to push an addEcommerceItem in between that contains all the remaining products (after removal) that I have in the cart?

_paq.push(["addEcommerceItem", "sku-456", "prod name", "category value", 30, 4]);

Also, the documentation says “if multiple units of that product are in the virtual cart, all of them will be removed”; so if I’m removing only 1 of sku-123, do I add everything again?

_paq.push(["addEcommerceItem", "sku-456", "prod name", "category value", 30, 4]);
_paq.push(["addEcommerceItem", "sku-123", "prod name2", "category value2", 20, 2]);

Finally, can we send event category, action and name information with these ecommerce events? So not only sending the item information but e_c, e_a and e_n with the same request.

This was long one. Thanks.

Hi, are you reloading the page after removing an item from the basket? If that’s the case you wouldn’t even have to use the “removeEcommerceItem” because after the reload an “addEcommerceItem” would kick in again and would add the items in the basket again (there wouldn’t be a sku-123 so it wouldn’t add). Basically instead of removing a single item, you just updating the cart again.
When it comes to the second part of your question, the ecommerce events are different from regular custom events, you won’t send event category, action and name information with these events. You would have to set it up separately (although it can be in the same tag but please note that it could increase significantly the number of actions because ecommerce events fire a lot ) API — Piwik PRO Analytics Suite 16.39 documentation

Thank Michal. This part is still not super clear for me.

I added item1 to my cart (with addEcommerceItem) and ran trackEcommerceCartUpdate. Then I navigated to another product page and added item2 to my cart. Do I only push addEcommerceItem for item2 here or do I need to push it for item1 as well? Or is it that the item1 cart addition information was already sent to Piwik Pro so I don’t need to run addEcommerceItem for it again?

My understading is it’s the first option because addEcommerceItem is not really an add-to-cart event. It’s a command that is used to create a virtual cart and store items in it until we can finalize the process with the purchase event (then we can clear the cart).

I would appreciate the clarification. Thank you!


Hey, you will need to push both items. CartUpdates are not sent to Analytics in Piwik PRO unless there is no trackOrder in the session. Then the last cartUpdate becomes an Abandoned cart and is sent to Analytics. When you refresh the page all data in cartUpdate is lost, that’s why you need eg. a dataLayer that holds the value of the cart all the time so that when you add a second item it remembers that there is something already in the basket. And then when an cartUpdate is fired again, it takes the data about both of the items from datalayer. This is also why you don’t need to use removeecommerceItem - when you refresh the page, the items are lost and the data need to be sent again. If the basket is updated (and has less products) it will the CartUpdate will simply take this data.

Thank you Michal, it’s clear now.

Hi @Michal_Szczerek,

I wanted to sync about this after the latest updates.

With the recent ecommerce updates, does the ecommerce tracking work similar to GA’s ecommerce tracking now? Set up ecommerce tracking | Piwik PRO help center

Previously, we had only cart updates and we needed to send all the products that’s in the cart at that moment. Now we just send the actual product information with ecommerceAddToCart() event (and ecommerceCartUpdate() when the session starts), right?


Hi! Yes, it’s quite similar setup to what was in GA3.
You have another article that talks about all the changes and how to adapt to them: Big changes in ecommerce: what's new and how to update your current tracking | Piwik PRO help center :slight_smile:

Thanks, good article! :sweat_smile:

Will the wordpress/woo plugin Piwik Pro be updated to include the new methods/functions?