Hello,
I have set up Piwik Pro using Google Tag Manager, by adding the entire code as a custom HTML tag that fires on all pages. While the sites are being tracked, the ecommerce events are not. I’ve gone through the tutorials and various forum entries, but I still can’t identify the issue.
The datalayer for ecommerce.items is configured according to GA4 specifications, and I’ve set up Piwik Pro Tag Manager events accordingly (please see the attached screenshots). However, when I check using the Tracker debugger, I can see product pages in the URL, but the Product page views are not recorded in the reports (neither are add to carts or purchases).
I’m quite desperate at this point and have no idea what the issue might be. The Tag Manager debugger is showing errors (please see the screenshots).
This is the error for view_item for example, that I get from debug:
<script>
(function () {
try {
var productsArray = ecommerce.items;
var skuKey = "item_id";
var nameKey = "item_name";
var priceKey = "price";
var quantityKey = "quantity";
var brandKey = "item_brand";
var variantKey = "item_variant";
var categoryKey = "item_category";
var categoryKey2 = "item_category2";
var categoryKey3 = "item_category3";
var categoryKey4 = "item_category4";
var categoryKey5 = "item_category5";
function replaceUndefinedValuesWithEmptyString(input) {
return input.map(function (item) {
return typeof item === 'undefined' ? '' : item;
});
}
function removeTrailingEmptyValues(input) {
var lastValue = input[input.length - 1];
if (input.length === 0 || (typeof lastValue !== 'undefined' && lastValue !== '')) {
return input;
}
return removeTrailingEmptyValues(input.slice(0, -1));
}
var products = productsArray.map(function (product) {
var categoryValue = replaceUndefinedValuesWithEmptyString(
removeTrailingEmptyValues([
product[categoryKey],
product[categoryKey2],
product[categoryKey3],
product[categoryKey4],
product[categoryKey5],
])
);
var productDimensionsValue = {};
return {
sku: product[skuKey],
name: product[nameKey],
category: categoryValue,
price: product[priceKey],
quantity: product[quantityKey],
brand: product[brandKey],
variant: product[variantKey],
customDimensions: productDimensionsValue,
};
});
window._paq = window._paq || [];
_paq.push(["ecommerceProductDetailView", products]);
} catch (e) {
e.message = 'The ecommerce product detail view tag failed to generate an analytics request due to misconfiguration. ' +
'Click the link on the right to identify the problem line. ' +
'For assistance, refer to the help center for proper ecommerce tracking setup: ' +
'https://help.piwik.pro/support/tag-manager/ecommerce-product-detail-view-tag/' + '\n' +
'Original error message: ' + e.message;
throw e;
}
})();
</script>
Could you please help me set up ecommerce tracking correctly?
Thank you!
Best regards,
David