Unique visitor with BOTH http and javascript API


#1

Hello everybody, I’m a french web developper trying to add Piwik tracking on an ecommerce website.

The probleme I have is that I decided to use http AND javascript API. In fact, I used the http api for my ‘add to cart’ page, which is managed with a classic post-redirect-get so i cannot add javascript on it.

I also don’t want to add javascript tracking code on the ‘add to cart’ button, because I know that every ‘add to cart’ procedure leads to my ‘cart/add’ url, but I don’t know where are all the buttons (and more buttons are susceptible to be added later on other pages).

Based on this, I have the attached the results that I obtain in my Piwik Back Office. The first user refers to all javascript trackings, while the second user is the http tracking.

I am wondering why is Piwik considering they are different. I mean : when I check the getVisitorId(), once in javascript and once in PHP, i successfully obtain the same user id. The only difference seems to be the user plugins and screen resolution, but I thought Piwik only uses this data when doing his heuristic process. Since my 2 “visitors” have the same Id, why should they be different ?

Maybe there is something I’m doing wrong… ?

Thank you for your anwsers


(Matthieu Aubry) #2

Yes, the two visitors should be tracked to the same user. do you use piwik 1.6?

you must call setForcedVisitorId, setIp, setTokenAuth and setAttributionInfo to have full analytics shared between PHP and JS API. See the Paypal example for a similar use case: 301 Moved Permanently


#3

Yep, thank you for your answer, it works now as it should :slight_smile: