Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecommerce : orders partially recorded #19001

Closed
BelairDigital opened this issue Mar 25, 2022 · 4 comments
Closed

Ecommerce : orders partially recorded #19001

BelairDigital opened this issue Mar 25, 2022 · 4 comments
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.

Comments

@BelairDigital
Copy link

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+020200123.34+debian91.gbp63c0bc
  • Server Operating System:
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@BelairDigital BelairDigital added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Mar 25, 2022
@sgiehl
Copy link
Member

sgiehl commented Mar 29, 2022

@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
Copy link
Author

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
Copy link
Member

sgiehl commented May 9, 2022

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
Copy link
Author

Hi,
Ok thank you,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced.
Projects
None yet
Development

No branches or pull requests

2 participants