Thanks, that is a very good idea, so currently I also have those two snippets available in my code:
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
{% if template == 'collection' %}
{% capture tag_list %}{% for tag in collection.all_tags limit:5 %}{{ tag }}{% if forloop.last == false %}::{% endif%}{% endfor %}{% endcapture %}
{% assign tag_array = tag_list | split: '::'%}
_paq.push(['setEcommerceView',
false, // Product name is not applicable for a category view.
false, // Product SKU is not applicable for a category view.
{{ tag_array | json }}, // Product category, or array of up to 5 categories
]);
{% endif %}
{% if template == 'product' %}
{% capture tag_list %}{% for tag in product.tags limit:5 %}{{ tag }}{% if forloop.last == false %}::{% endif%}{% endfor %}{% endcapture %}
{% assign tag_array = tag_list | split: '::'%}
_paq.push(['setEcommerceView',
{{ product.id }}, // (Required) productSKU
{{ product.title | json}}, // (Optional) productName
{{ tag_array | json }}, // (Optional) categoryName
{{ product.price | money_without_currency }} // (Optional) price
]);
{% endif %}
_paq.push(['trackPageView']);
and this one
var _paq = window._paq = window._paq || [];
_paq.push(['addEcommerceItem',
{{ item.product_id }}, // (Required) productSKU
{{ item.title | json }}, // (Optional) productName
{{ tag_array | json }}, // (Optional) productCategory
{{ item.final_price | money_without_currency }}, // (Recommended) price
{{ item.quantity }} // (Optional, defaults to 1) quantity
]);
_paq.push(['trackEcommerceCartUpdate', {{ item.final_price | money_without_currency }}]);
if I understand correctly I should rather use the mtm variable that is there in parallel right?
Also for the checkout page I have the same “combination” with mtm und paq should I also use just one here?
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="...";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '6']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
{% if first_time_accessed %}
{% for line_item in checkout.line_items %}
{% capture tag_list %}{% for tag in line_item.product.tags limit:5 %}{{ tag }}{% if forloop.last == false %}::{% endif%}{% endfor %}{% endcapture %}
{% assign tag_array = tag_list | split: '::'%}
_paq.push(['addEcommerceItem',
{{ line_item.product_id }}, // (Required) productSKU
{{ line_item.title | json }}, // (Optional) productName
{{ tag_array | json}}, // (Optional) productCategory
{{ line_item.final_price | money_without_currency | replace: ",","."}}, // (Recommended) price
{{ line_item.quantity }} // (Optional, defaults to 1) quantity
]);
{% endfor %}
_paq.push(['trackEcommerceOrder',
{{ checkout.order_id }}, // (Required) orderId
{{ checkout.total_price | money_without_currency | replace: ",","."}}, // (Required) grandTotal (revenue)
{{ checkout.subtotal_price | money_without_currency | replace: ",","."}}, // (Optional) subTotal
{{ checkout.tax_price | money_without_currency | replace: ";","."}}, // (optional) tax
{{ checkout.shipping_price | money_without_currency | replace: ",","."}}, // (optional) shipping
{{ checkout.discounts_amount | money_without_currency | replace: ",","."}} // (optional) discount
]);
{% endif %}
</script>
<!-- End Matomo Code -->
Can I track the same e-Commerce events with mtm?
Sorry for the strange questions