How to correctly add addEcommerceItem tracking?


I have already added matomo js tracking code website and all is working fine. I’m stuck, how to add _paq.push([‘addEcommerceItem’, parameter.

Is there should be any js script before/after?

    product_id, // (Required) Product identifier (SKU)
    product_name, // (Optional) Product name
    false, // (Optional) Product category or an array of up to 5 categories.
    price, // (Optional) Product price
    item_quantity // (Optional) Product quantity (default is 1)
  return false;

Both setEcommerceView and trackEcommerceOrde work fine, but add to cart don’t work.

Do I need to add any event snippet like facebook meta when someone clicks on the chosen link or button?


function pixel_add_to_cart(url) {
  var callback = function () {
    if (typeof(url) != 'undefined') {
      window.location = url;