Getting 'cross-domain' info from piwik.js 1x1.gif response from a cookie or response header

Hello

How can I use/read either a response cookie or response header after loading the 1x1 gif web beacon when piwik.js is run.

Example: say www.client1.com , www.client1.com , … www.clientN.com and a single piwik tracking server piwik.trkservice.com based upon a cookie or a header returned from the 1x1 web beacon response I want to take an action like displaying a java-script alert/pop-up.

It is important to note my tracking beacon always comes from “piwik.trkservice.com” a different domain from my clients in which I provide tracking services for.

I will try to explain what I am looking for below.

Basically I was hoping to “slightly modify” piwik.js in the getImage(…) call by linking in a new function performPopUpOnCookieorHeader(…). That calls one of two function which I do not know how to write wither getCookieValFromWebBeaconReq(…) or getHeaderValFromWebBeaconReq(…)


// new function in piwik.js ...
function performPopUpOnCookieorHeader(....) {
    // On proper response header or response cookie from the 1x1 beacon response
    // I want to show an alert but I do not know how to read/use the cookies
    // returned with the response from piwik.trkservice.com/1x1.gif -or-
    // alternatively I don't know how to read any headers I send with the 1x1
    // image.  Of course I trying to take an action via cross-domain information.
    // How would I get this info?  I need Help writing a function like one below.
    //
    //  val = getCookieValFromWebBeaconReq("lookinto");
    //  -or-
    //  val = getHeaderValFromWebBeaconReq("x-header-lookinto");

    val = ???? // one of the above functions ....
    alert('Please consider looking into ' + val);[/indent]
}

// modified piwik.js function ...
function getImage(url, delay) {
    var now = new Date(),
    image = new Image(1, 1);
    expireDateTime = now.getTime() + delay;
    image.onload = function() { performPopUpOnCookieorHeader(...); }
    image.src = url;
}

My issue is that I can not seem to (or do not know how) read any of the cookies that com from my 1x1 site (cross-domain issue?) when the page with the piwik.js script loads the 1x1 gif from a different domain. Alternatively I don’t know how to read the response headers which I could also set in place of the cookie in the response of the 1x1 image/web-beacon.

Note, I use HTTP FOX (a request response debugger) that is a plug-in in Mozilla Firefox, which is Java-script and it shows all the headers and cookies set correctly for the piwik.trkservice.com/1x1.gif (domain: piwik.trkservice.com). Since HTTP FOX is java-script I imagine this is indeed doable with the right java-script hooks - but I can not easily figure them out.

Thanks in Advance,

Jon Strabala

First, since we use getImage, there is no cross domain issue with tracking. The only issue is that a visitor may be blocking third-party cookies.

Second, you can modify piwik.js as you like under the terms of the GPL. In the long run, it might be better to propose a hook so your customization would be implemented as a plugin to piwik.js.

However, I don’t see the purpose of your use case, given disdain for popups and (my) general UI concerns about interrupting the visitor’s experience on one’s site.

[quote=vipsoft @ Apr 11 2010, 01:04 PM) <{POST_SNAPBACK}>

First, since we use getImage, there is no cross domain issue with tracking. The only issue is that a visitor may be blocking third-party cookies.

I never said there was an issue with the way piwik does cross domain tracking, I just want to get some information back from either cookie or a header when the 1x1 gif is served.
QUOTE (vipsoft @ Apr 11 2010, 01:04 PM) [<{POST_SNAPBACK}>](index.php?act=findpost&pid=30611)
Second, you can modify piwik.js as you like under the terms of the GPL. In the long run, it might be better to propose a hook so your customization would be implemented as a plugin to piwik.js.
Modifying under GPL is fine for me, proposing a plugin seems a "long term" process that may never get implemented and also would not fit a client deadline.
QUOTE (vipsoft @ Apr 11 2010, 01:04 PM]However, I don't see the purpose of your use case, given disdain for popups and (my) general UI concerns about interrupting the visitor's experience on one's site.[/quote] Look I agree with you about pop-ups in general however the actual "use case" is critical for the users experience in the instant case if the user isn't notified that his bill is due his ISP service would be terminated (think of a prepaid internet dongle purchase but with no voice only data minutes) - definitely a "sub-standard" experience considering the ISP has no e-mail or U.S. postal address. Yes, I know this is a bit weird but the real world sometimes need odd solutions.

There are other methods I can use like JSONP example Cross-domain communications with JSONP, Part 1: Combine JSONP and jQuery to quickly build powerful mashups but I wold rather a simple solution using piwik since I already use it and I thought the image gif might be a simple elegant transport to send data back to the client session.

As to third party cookies I want to avoid this, I was actually more curious if the headers from the image response could feed cross domain information to java-script to drive an overlay pop-up of a different domain than the gif tracking site.

piwik.js already has a getCookie() method; in getImage(), you’ll have to write your own onload handler.

Yes I know that but the getCookie() function only reads cookies form the current domain of the webpage visited NOT from the domain of the tracking site. This is why I was looking for a ‘hook’ into the headers that come back with the image from the tracking site.

I have indeed written my own handler - but my cookies can not be looked up, e.g. cross domain and I do not want to use third party cookies.

Sorry. You’ll have to roll your own solution in the interim if you can’t wait for http://dev.piwik.org/trac/ticket/557