Ecommerce Analytics API question


I recently installed Piwik to a small site I am running and had a question about the Ecommerce API. From the documentation:

We are instructed to call the 2 methods on the Order completion page of our ecommerce site:

addEcommerceItem(productSKU, productName, productCategory, price, quantity)
trackEcommerceOrder(orderId, grandTotal, subTotal, tax, shipping, discount)

with “_paq.push([‘trackPageView’]);” to be included in the Order confirmation page.

I have a question for the following scenario:

I have affiliate links on my site that link my customers away from my site to other vendor sites who handle order fulfillment. I want to add an Javascript event handler to the “click” event for the element that sends the customer to the vendor and have my code call addEcommerceItem and trackEcommerceOrder before they are redirected. Do these method calls get handled asynchronously or synchronously, i.e. will it register the order before they are redirected to the vendor? If it is synchronous I know it should but I am not sure what exactly happens after the push method is called on the array.

Thanks in advance,


to make this work, you need to add a “timeout” in javascript to leave the browser enough time for sending the http request to piwik. this is the technique we use in piwik.js to track “outlinks” (by default timeout is 500ms)

Thanks matt will do