Objects and arrays in Matomo Tag Manager

Hi everyone,

unfortunately, I don’t know how to access an array with multiple products in Matomo Tag Manager. We use the cloud variant and have already written to support, but have not received a detailed answer yet. Maybe you guys can help me further.

Example:

The user adds the following products to his shopping cart:

product_a → quantity 2
product_b → quantity 4.

Then the user submits the form to order these goods.
I.e. the dataLayer push would then look like this:

<script> 
window._mtm = window._mtm || []; 
  window._mtm.push({ 
    'event': 'order_form', 
    'order': { 
    'products': [
      { 
      'product_name': 'product_a', 
      'quantity': '2' 
      },
      { 
      'product_name': 'product_b, 
      'quantity': '4' 
      }
    ] } 
}); 
</script>

We have an array of 2 products here. How can I then make this array readable in Matomo Tag Manager?

How do I need to configure the tag and variable to show me the data from the array in Matomo Analytics? In the dataLayer push, the product data is displayed correctly. I think there is still a setting missing in the Matomo Tag Manager.

Important: it is not a “real” eCommerce event in our case, beacuse you only request the products via the order form at first. So no price is given and the user does not have to pay anything yet. It is just a normal form with product_name and quantity.

Also, is there a way to clean up the previous ecommerce object, like this: window._mtm.push({order_form: null}); ?

Thanks a lot for your help!

Best,
Britta

Hi

Sorry, the answer may be a bit late.

I’m notr I understood coorectly, but from what I got :

  • I suppose you could simply call the content of the Datalayer property ‘products’ in a Datalayer Variable… Then this variable value would be the array…

Let us know if it’s not really what you want to do

best rgds

Laurent