Piwik and new EU cookie law

Hi,

Today I’ve been made aware of new legislation governing the use of cookies on websites. Cookies which track usage must be “opt in”

http://www.theinquirer.net/inquirer/news/2032237/websites-cookie-clampdown?WT.rss_f=&WT.rss_a=Websites+face+a+cookie+clampdown

I know Piwik already has an opt in facility - however, does Piwik by default come under this legislation - or does the way it track usage fall outside of this law?

Kind regards,

Rob

Starting with Piwik 1.2, these are first party cookies. Because every website is different, Piwik doesn’t/can’t directly provide an opt-in.

It’s a catch-22. If the visitor doesn’t opt-in, piwik.js can’t record a cookie that say’s he/she didn’t opt-in; similarly, the server can’t use a session cookie to remember that a visitor didn’t opt-in.

So the net-effect is that a visitor who doesn’t opt-in, is going to get prompted to opt-in on every page view / refresh. It’s going to make for very poor user experiences IMHO.

If the proposed changes come into force in the UK, web site operators in the UK could do something like this


var tracker = Piwik.getTracker( 'http://example.co.uk/piwik.php', '1' );
var visitorId = tracker.getVisitorId();
var optin = false;

if (!visitorId) {
    optin = confirm( 'Opt-in to use cookies?' );
}

if (optin || visitorId) {
    tracker.enableLinkTracking();
    tracker.trackPageView();
    // etc
}

Scratch that. getVisitorId() returns an id whether or not the cookie was created. I’ll add a new API method (e.g., getVisitorCookie()).

Thanks vipsoft - a new api method would be fantastic :slight_smile:

Hopefully the law wont be enforced. I really can’t see it working - it’s a bad law which will force companies to host their websites outside of the EU.

In 1.3, the code would be:



var tracker = Piwik.getTracker( 'http://example.co.uk/piwik.php', '1' );
var info = tracker.getVisitorInfo();
var optin = false;
var alreadyTracking = info[0] != '1' || info[3] > 0;

if (!alreadytracking) {
    optin = confirm( 'Opt-in to use cookies?' );
}

if (optin || alreadyTracking) {
    tracker.enableLinkTracking();
    tracker.trackPageView();
    // etc
}

Wow! that was fast :slight_smile: thanks! :slight_smile:

Hi all,

anyone know how i can do this today with the piwik 2.15.0?

Thanks
Bastian

Hi vipsoft,

do you have the Code also for piwik 3.3.0?

Thanks
Jeannine