@robocoder opened this Issue on May 4th 2011 Contributor

See http://forum.piwik.org/read.php?3,76449

Basically, there would be a method that could be called to read the (third-party) piwik_visitor cookie, and set the visitorUUID in piwik.js

Pseudo-code:

function setVisitorIdFromServerCookie( cookieName = 'piwik_cookie' ) {
    var id = getCookie(getCookieName('id'));
    // only if the first party cookie doesn't already exist
    if(!id) {
        id = getCookie( cookieName );
        // only if the server cookie exists
        if(id) {
            // (oversimplified...in reality, you have to strip the signature first)
            visitorUUID = id;
        }
    }
}

Alternately, we add a method that allows the server cookie name to be defined, and piwik.js automatically recognizes it in loadVisitorIdCookie(), e.g.,

    ...
    piwikTracker.setServerCookieName('piwik_visitor');
    piwikTracker.trackPageView();
@mattab commented on May 4th 2011 Member

How will you read the 3rd party cookie in JS? the only way I can think of is with jsonp but that's a massive overhead (2 requests instead of 1)

@anonymous-piwik-user commented on May 4th 2011

I might not quite understand how this works, but if the user's browser blocks 3rd party cookies, this wouldn't be able to join two visits. Right?

@robocoder commented on May 4th 2011 Contributor

right. if third party cookies are blocked, this idea won't work.

it assumes the third party cookie is available when the piwik.js resource is loaded from the same domain as the image tracker.

feel free to consider a server-side solution that overcomes these limitations.

This Issue was closed on May 4th 2011
Powered by GitHub Issue Mirror