Ecommerce how to use the getEcommerceItems function


I’m tracking my products orders on my ecommerce website by using the functions addEcommerceItem() and trackEcommerceCartUpdate() like this :

// Product Array
  "01234567890", // (required) SKU: Product unique identifier
  "Ecommerce Analytics Book", // (optional) Product name
  "Books", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
  9.99, // (Recommended) Product Price
  1 // (Optional - Defaults to 1)

// Pass the Cart's Total Value as a numeric parameter
_paq.push(['trackEcommerceCartUpdate', 15.5]); 

source :

It works fine. But I don’t understand how to use the getEcommerceItems() function.
I get nothing with _paq.push([‘getEcommerceItems’]);
How am I supposed to use it correctly ?

Thanks for the help.


The savest way to use such functions (as it runs asynchronously whenever Matomo has finished processing all other _paq commands) is something like this:

_paq.push([function () {

If you know for sure that at the time your Javascript runs, Matomo has already been initialized, you can also use something like this

let tracker = Piwik.getAsyncTracker()
1 Like