@BelairDigital opened this Issue on March 25th 2022

All of the ecommerce orders are not recorded in Matomo.

Expected Behavior

just a few orders are recorded

Current Behavior

we have 5 other websites with the same Matomo tracking (and same back-office) where all conversions are well recorded but only for one website we have just a few orders

Possible Solution

Steps to Reproduce (for Bugs)

here how the matomo code is
1) Default Matomo code put on all pages:

var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
    var u="//matomo.kostparis.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', "4"]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

Code put on the product page:

'use strict';

var data = {"sku":"1233631656","name":"BRIGADE","price":200,"category":"Derbies"};

if (window._paq) {
    window._paq.push([
        'setEcommerceView',
        data.sku,
        data.name,
        data.category,
        data.price
    ]);
    window._paq.push(['trackPageView']);
}

Script put on the cart page:

'use strict';

var cart = {"products":[{"sku":"123363165637","name":"BRIGADE","category":"Derbies","price":"200.0000","qty":1}],"total":200};

if (window._paq) {
    var i = 0,
        product;

    for (i; i < cart.products.length; i++) {
        product = cart.products[i];
        window._paq.push([
            'addEcommerceItem',
            product.sku,
            product.name,
            product.category,
            product.price,
            product.qty
        ]);
    }
    window._paq.push(['trackEcommerceCartUpdate', cart.total]);
}

Script on the category page:

'use strict';

var data = {"category":"Femme"};

if (window._paq) {
    window._paq.push(['setEcommerceView',
        false,
        false,
        data.category
    ]);
    window._paq.push(['trackPageView']);
}

Script on the order confirmation page (checkout success):

'use strict';

var data = {"id":"19000000132","total":221.66,"subtotal":206.66,"tax":39.9933,"shipping":15,"discount":0};

if (window._paq) {
    window._paq.push(['trackEcommerceOrder',
        data.id,
        data.total,
        data.subtotal,
        data.tax,
        data.shipping,
        data.discount
    ]);
}

Context

Your Environment

  • Matomo Version: 4.8.0
  • PHP Version: 7.2.27-1+0~20200123.34+debian9~1.gbp63c0bc
  • Server Operating System:
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@sgiehl commented on March 29th 2022 Member

@BelairDigital that loos a bit like a implementation issue. At which position is the Matomo tracking code loaded? Is it placed in the head of the website or at the end of body? Did you check if the ecommerce tracking isn't triggered as window._paq is not yet defined? Or is the tracking request sent out, but doesn't appear in Matomo?

@BelairDigital commented on May 6th 2022

Hi, thanks for your anwser.
The code is placed at the head of the website.
Some ecommerce transactions are sent but not all of them, that why I do not understand.
We have 4 websites, everything is ok and has the same configuration but only one website transactions and revenues do not appear totally on Matomo.

@sgiehl commented on May 9th 2022 Member

Based on the code you provided, the only reason why it might not be tracked is, that window._paq might not be available at that point, causing the tracking to be skipped. You could maybe try to change your code, to do a simple console.log if that is the case, to see if this is the problem.

@BelairDigital commented on May 13th 2022

Hi,
Ok thank you,

This Issue was closed on May 13th 2022
Powered by GitHub Issue Mirror