Hi Piwik Community!
I have tried setting up an Order Confirmation Tag for Ecommerce Tracking that needs to be fired on one of our old GA3 Ecom Datalayer events.
This is how the Datalayer Event looks like(with example data in it):
{
ecommerce: {
currencyCode: "EUR",
purchase: {
products: [
{
name: "Example Product Name",
id: "12345",
materialId: "AB12345",
price: "11,50",
quantity: 1,
dimension11: "Test"
}
],
actionField: {
id: "1111112",
revenue: 21.95,
tax: 3.2,
shipping: 10.45
}
}
},
event: "eec.purchase"
This is how the Order Confirmation Tag looks like that fires on āeec.purchaseā(below). I have tried to modify so it is according to Piwiks rules regarding the accepted data and data types for the different fields. The variable āsubtotalā is a calculation we need to do also to get the correct data:
<script>
(function () {
var products = {{ ecommerce }}.purchase.products;
var grand_total = {{ ecommerce }}.purchase.actionField.revenue;
var grand_shipping = {{ ecommerce }}.purchase.actionField.shipping;
products.forEach(function(product){
var subtotal = parseFloat(grand_total) - parseFloat(grand_shipping);
var priceWithDot = parseFloat(product.price.replace(",", "."));
_paq.push(["addEcommerceItem", product.sku, product.name, product.category, priceWithDot, product.quantity]);
});
_paq.push(["trackEcommerceOrder",{{ ecommerce }}.purchase.actionField.id, {{ ecommerce }}.purchase.actionField.revenue, {{ subtotal }}, {{ ecommerce }}.purchase.actionField.tax, {{ ecommerce }}.purchase.actionField.shipping, {{ discount }}]);
})();
</script>
When I debug the tag while doing a purchase, the tag gets triggerd but no data is being sent to Piwik from what I can see in the Tracker Debugger. I get this error in the Console instead:
What is the issue here? And how can i modify the tag so it works?
Thanks in advance!