[solved] Ecommerce tracking

Hi all,

I need some help setting up the tracking of ecommerce. Somehow I can’t seem to get i working. Here is my code (note that it’s taken from the examples on this site):


piwikTracker.addEcommerceItem(
"9780786706211", // (required) SKU: Product unique identifier
"Endurance: Shackleton's Incredible Voyage", // (optional) Product name
"Adventure Books", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
8.8, // (recommended) Product price
1 // (optional, default to 1) Product quantity
);
piwikTracker.trackEcommerceCartUpdate(35);
piwikTracker.trackEcommerceOrder(
"130", // (required) Unique Order ID
35, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
30, // (optional) Order sub total (excludes shipping)
5.5, // (optional) Tax amount
4.5, // (optional) Shipping amount
false // (optional) Discount offered (set to false for unspecified parameter)
);

piwikTracker.trackPageView();

I can see the cart in the header of the visitors log (where browser/ip/etc is) but the ecommerce screen stays empty and the cart does not show in the pages-section of the visitors log.

Can someone see what is wrong here?

Ok I have tested some more. If I remove the piwikTracker.addEcommerceItem call and the piwikTracker.trackEcommerceCartUpdate call, it will show the cart and Revenue: 350 € in the pages section of the visitors log and the orders are added to the ecommerce section.

But I still can’t see what product is ordered and the documentation clearly shows I need to call addEcommerceItem first

Any help is welcome

I’m not sure if it is related but I seem to have the same problem with custom variables


piwikTracker.setCustomVariable(1,"test","test2" ) ;

does not seem to work.

All these cases should work fine. If you can, prepare a test file with your JS calls that don’t work and open in a different browser. if you really have no tracking and no error in the logs, put the code to reproduce here and we’ll investigate!

Well it’s exactly like the code I gave above:

This is the verion I’m using now:

try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);

piwikTracker.addEcommerceItem("123456");
piwikTracker.trackEcommerceOrder("151", 100);

piwikTracker.trackPageView();

} catch( err ) {document.title=err.message}

This will give the following in the user log (note the [ordererd] bit):


Fri 30 Mar - 22:11:14 (1s)   [Netherlands, Provider Upc]   [Chrome 17.0, Plugins: flash, java, quicktime, windowsmedia, silverlight]   [Linux, 1920x1080]   #0  - [ordered] - IP: x.x.x.x
Direct Entry
Pages:  [Title - Fri 30 Mar 22:11:14] 

Now if I remove the addCommerce line:


try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);

piwikTracker.trackEcommerceOrder("152", 100);

piwikTracker.trackPageView();

} catch( err ) {document.title=err.message}

It will show this in the visitors log


Fri 30 Mar - 22:21:57 (10 min 46s)   [Netherlands, Provider Upc]   [Chrome 17.0, Plugins: flash, java, quicktime, windowsmedia, silverlight]   [Linux, 1920x1080]   #0  - [ordered] - IP: x.x.x.x
Direct Entry
Pages:  [Title - Fri 30 Mar 22:11:14] Revenue:  100 € 

There is nothing in the apache error log and there is no php error log and both logger_error and logger_exeption tables are empty.

Can I somehow see the contents of the ecommerceItems variable (I’m not too good in js)?

Ok Using firebug I can see it creates the following raw request:


idgoal=0&ec_id=154&revenue=100&ec_st=undefined&ec_tx=undefined&ec_sh=undefined&ec_dt=undefined&ec_items=%5B%5B%22123456%22%2C%22%22%2C%22%22%2C0%2C1%5D%5D

and after the getRequest call:


idgoal=0&ec_id=154&revenue=100&ec_st=undefined&ec_tx=undefined&ec_sh=undefined&ec_dt=undefined&ec_items=%5B%5B%22123456%22%2C%22%22%2C%22%22%2C0%2C1%5D%5D&idsite=2&rec=1&r=267422&h=22&m=43&s=55&url=http%3A%2F%2Flocalhost%2Ftest6.html&_id=96e1634a24e1a558&_idts=1333006531&_idvc=6&_idn=0&_refts=0&_viewts=1333128820&_ects=1333139903&pdf=0&qt=1&realp=0&wma=1&dir=0&fla=1&java=1&gears=0&ag=0&res=1920x1080&cookie=1

Do you see anything strange in that?

I have tried in different browsers and I have with a new database but I can’t get it working. :frowning:

I found it, this old server still had magic quotes on which screwed things up a bit. Disabling that (which should have been done anyway) fixed the issue.