Image Tracker proxy calls API with socket

While integrating this great Analytics tool on my websites, I faced several problems:
a. I want to use the tracker API but I don’t want to loose the javascript options to retrieve the client info, so the 1px Image method is the preferred way.
b. I don’t want the location of the endpoint tracker URL visible in the HTML
c. Same with the auth token
d. I don’t want to depend on possible not installed PHP extensions to use the API.
e. My piwik is installed on an account that has no SSL certificate. I want to call the tracker from within HTTPS sites, without breaking the secure page. So the tracker must be embedded on the same site (as a proxy) and just forward the request server-side thru the API.

Solved it by creating a class that extends the default tracker API class. This child class has two methods which would be nice to be included in the original class. This class can be downloaded here:
http://cdyweb.com/Piwik.class.zip

MyPiwikTracker::sendRequest
Overrides the original sendRequest and provides a pure PHP method of calling the API endpoint, using a simple TCP socket.

MyPiwikTracker::doTrackPageViewFromImageData
Is called from any script that is the SRC for the 1px image.
This is linked to my modified tracking code in javascript.
See the source of http://www.cdyweb.com/

Anyone interested in using or changing my extended tracker class is free to do so.

Interesting, I have a question to your method. I’m facing problem, that for extensions such as Ghostery even noscript part is blocked (not executed), thus if having any piwik js code no visitor counted at all. Could this be altered in a way, that based on whether it returns some custom js info it either generated only img or just js code (at least looking at source in your page you still have both js + noscript fallback there).

cheers

Getting around Ghostery requires a mod to the embedded tracker script. I’ve just experimented a bit, the trick is to implement the exception handler. The default Piwik tracker code has an empty exception handler. A missed opportunity b/c this is where you can respond to things like Ghostery. My exception handler adds a new IMG object to the DOM body, the src is obviously the same as the img:


    var img = document.createElement('img');
    img.src = 'where ever the tracker is';
    document.body.appendChild(img);

Tested it with Ghostery, the page gets tracked anyway. Happyness!

Thanks a lot, it works perfectly with Ghostery :slight_smile:

Hi,

i know this post is old, but i am looking for a method to track visitors with the proxy piwik.php if script is disabled and could not find anithyng on the web. if i underst it corectly your aproach will do the trick. could you pleas describe in detail how to do this?

thx.

[quote=john01]
Hi,

i know this post is old, but i am looking for a method to track visitors with the proxy piwik.php if script is disabled and could not find anithyng on the web. if i underst it corectly your aproach will do the trick. could you pleas describe in detail how to do this?

thx.[/quote]

Hello John

I am also finding the same solution. please let you PM me if you get the above solution.
Prior responce would be appriciable…
Thanx


web development ghaziabad