matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.8k stars 2.64k forks source link

Use Web storage to persist data when cookies are disabled #4015

Open anonymous-matomo-user opened 11 years ago

anonymous-matomo-user commented 11 years ago

This is a proposal regarding http://piwik.org/faq/general/#faq_43

There are cases where cookies are not supported either because the browser (user) has disabled them, or because the tracking code is running under the file:// protocol and not the http:// protocol. The latter case applies to following scenarios (among others):

  1. The tracking code (javascript) is in a page and the page is loaded statically (file://) inside a WebView in a native app (Android/iOS).
  2. The tracking page is loaded inside a native WebView which has disabled the cookies.

In order to be able to produce unique visitor ids on the client and persist them on the client side, the HTML5 localStorage and sessionStorage could be used a a fallback mechanism.

The proposed flow inside piwik.js could be like this:

#!javascript
if (cookiesSupported()) {
   // use original/current piwik.js code
} else if (html5storageSupported() {
   // fall back to this and store the visitor id and the custom variables
   // using HTML5 localStorage and sessionStorage.
} else {
   // use the rule of thumb to match the visitor on the server
   // using the visitor settings.
}

Keywords: cookies HTML5 localstorage sessionstorage

robocoder commented 11 years ago

I'm not against this, but it's more complicated since we support opt-out. Side note: the evercookie proposal in #1725 was closed.

anonymous-matomo-user commented 11 years ago

Using HTML5 localStorage does not break the opt-out mechanism. Instead of removing a cookie (or creating a no-track cookie) it can be that a localStorage variable that is created instead. Evercookie is by far a different approach. It creates a zombie cookie and it is not recommended for Piwik, I agree with you. All I'm suggesting is to have an alternative to store something on the client.

mattab commented 11 years ago

Thanks for the proposal. I like the idea!

How much code would this represent to be added to piwik.js? Would you submit such improvement?

hpvd commented 10 years ago

hmm should we always store piwik identification directly on both places? To make it redundant? Maybe not by default but having to the possibility to activate it?