Ecommerce tracking doesn't send any data

Hi! A week ago I have set up Piwik… it works fine! But I can’t get any data into ecommerce module, I tried different settings, but without success. Now, I display this code on final order page:

window.dataLayer.push({
event: “order_confirmation”,
products: [
{
sku: “342”,
name: “Klimt, Gustav - Portrét Adele Bloch Baurer I”,
category: “101”,
price: 760,
quantity: 1
},],
{orderId: “2306195637”,
grandTotal: “760”
}

});

var _paq = _paq || ;
var products = {{ products }};
products.forEach(function(product){
_paq.push([“addEcommerceItem”,product.sku, product.name,product.category, product.price, product.quantity])
});
_paq.push([“trackEcommerceOrder”,{{ order_id }}, {{ grand_total }}]);

and below it is:

(function(window, document, dataLayerName, id) {
window[dataLayerName]=window[dataLayerName]||,window[dataLayerName].push({start:(new Date).getTime(),event:“stg.start”});var scripts=document.getElementsByTagName(“script”)[0],tags=document.createElement(“script”);
function stgCreateCookie(a,b,c){var d=“”;if(c){var e=new Date;e.setTime(e.getTime()+24c60601e3),d=“; expires=”+e.toUTCString()}document.cookie=a+“=”+b+d+“; path=/”}
var isStgDebug=(window.location.href.match(“stg_debug”)||document.cookie.match(“stg_debug”))&&!window.location.href.match(“stg_disable_debug”);stgCreateCookie(“stg_debug”,isStgDebug?1:“”,isStgDebug?14:-1);
var qP=;dataLayerName!==“dataLayer”&&qP.push(“data_layer_name=”+dataLayerName),isStgDebug&&qP.push(“stg_debug”);var qPString=qP.length>0?(“?”+qP.join(“&”)):“”;
tags.async=!0,tags.src=“https://slavneobrazy.containers.piwik.pro/“+id+”.js”+qPString,scripts.parentNode.insertBefore(tags,scripts);
!function(a,n,i){a[n]=a[n]||{};for(var c=0;c<i.length;c++)!function(i){a[n][i]=a[n][i]||{},a[n][i].api=a[n][i].api||function(){var a=.slice.call(arguments,0);“string”==typeof a[0]&&window[dataLayerName].push({event:n+“.”+i+“:”+a[0],parameters:.slice.call(arguments,1)})}}(i[c])}(window,“ppms”,[“tm”,“cm”]);
})(window, document, “dataLayer”, “5c9c3752-3297-492b-8a6d-99dcf8a5f2fc”);

and console.log says: Uncaught TypeError: Cannot read properties of undefined (reading ‘push’)

Any hint welcomed!

Thank you

Petr

Hi,

Make sure that you are following Piwik PRO’s help center article while creating the ecommerce setup. Here is a link to the article: Set up ecommerce tracking | Piwik PRO help center

From what you described in the thread, I see that you might be using old ecommerce methods (trackEcommerceOrder, addEcommerceItem). You can find the new ecommerce methods here: API — Piwik PRO Analytics Suite 17.3 documentation

Also, I noticed that you missed a closing tag in your _paq.push([‘ecommerceProductDetailView’, …])
image

Thank you! it was a last version from this forum (How to set up ecommerce tracking?)… I change the code:

_paq.push([
“ecommerceOrder”,
[
{
sku: “2128”,
name: “Renoir, Auguste - Váza chryzantém (Dahlias)”,
category: “101”,
price: 714,
quantity: 1
},],
{ orderId: “2306195640”,
grandTotal: “714”}]);

and I got any parser error but this: “Uncaught ReferenceError: _paq is not defined”. I guess that I need to initialize all the _paq function somewhere… But I don’t know how :slight_smile:

Please try adding var _paq = window._paq || []; before the _paq.push([“ecommerceOrder”, …]) method.

Yes! It works now :slight_smile: Thank you so much!