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

Piwik does not delete the order items when I call trackEcommerceCartUpdate #4251

Closed
anonymous-matomo-user opened this issue Oct 28, 2013 · 4 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@anonymous-matomo-user
Copy link

I'm using Piwik with Ecommerce option, and use JS for ecommerce triggering.

I use trackEcommerceCartUpdate on every add and delete operation. It loops the items array and pushes every time with SKUs. Then I call trackEcommerceCartUpdate, and trackPageView. While adding element everything is alright.

When I remove an element from the items array, it's deleted. Then again I call track function with the same array, but it sends the removed elements, too. When I check visitor logs, total revenue left in order looks correct, but the item that I deleted is still on log.

I checked the request, in query parameters ec_items attribute has the removed elements, too.

var orders = Array();

function addToCart(itemId){
    orders.push(itemId);
    trackIt();
}
function removeFromCart(itemId){
    var index = orders.indexOf(itemId);
    if (index > -1) {
        orders.splice(index, 1);
    }
    alert(orders.length);
    trackIt();
}
function completeOrder(){
    window.location.href="http://localhost/~sakir/completeOrder.php?orders=" + orders.join();
}

function trackIt(){
    ordersToTrack = orders;
    element = null;
    totalCount = 0;

    for (var i = 0; i < ordersToTrack.length; i++) {
      element = ordersToTrack[i];

    _paq.push(['addEcommerceItem',
    "978078675621" + element, // (required) SKU: Product unique identifier
    "Room " + element, // (optional) Product name
    [Books"]("Adventure), // (optional) Product category, string or array of up to 5 categories
    element*100, // (recommended) Product price
    1 // (optional, default to 1) Product quantity
    ]);
    totalCount = totalCount + (element*100);

    }

    _paq.push(['trackEcommerceCartUpdate',
    totalCount]); // (recommended) Cart amount
    _paq.push(['trackPageView']);

}
@mattab
Copy link
Member

mattab commented Oct 28, 2013

the ecommerceItems array holding ecommerce items is not reset at the end of trackEcommerceCartUpdate.

Therefore if you are triggering this HTTP request without the item, in the same page instance as the previous cart update which had the item, then you need to manually delete the item from the JS object:

addEcommerceItem for the sku that was deleted and set all values to ""

This should remove the item from the cart. Reopen if you stil have the problem and please post a complete test script to reproduce

@anonymous-matomo-user
Copy link
Author

Attachment:
Screen Shot 2013-10-31 at 1.58.22 PM.png

@anonymous-matomo-user
Copy link
Author

I've tried to set all values to "", but still I can see the item on the cart without values.
function removeFromCart(itemId){

    _paq.push(['addEcommerceItem',
    "978078675621" + itemId, // (required) SKU: Product unique identifier
    "", // (optional) Product name
    "", // (optional) Product category, string or array of up to 5 categories
    "", // (recommended) Product price
    "" // (optional, default to 1) Product quantity
    ]);

    var index = orders.indexOf(itemId);
    if (index > -1) {
        orders.splice(index, 1);
    }
    alert(orders.length);
    trackIt();
}

@mattab
Copy link
Member

mattab commented Nov 1, 2013

Since it is not a common use case, it may need more. can you please post

  • the html minimal code to reproduce,
  • expected behavior (in Visitor Log)
  • behavior you are seeing

I will investigate then

@anonymous-matomo-user anonymous-matomo-user added this to the 2.0.3 - Piwik 2.0.3 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Major Indicates the severity or impact or benefit of an issue is much higher than normal but not critical. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

2 participants