Matomo Creating Cookie in Local Storage with DNT enabled


(Ben) #1

Hello,

As far as I understand, Matomo is still creating cookies in persistent storage despite DNT being enable on Matomo and by the user browser.

The cookies being created are:
_pk_id.1.bc26
_pk_ses.1.bc26

The browser being tested is:
Firefox in version 62.0.3

I have not found any entries in the forum or within githib that talk about this. Can someone assist me with how to make sure Matomo respects DNT for these cookies?

Thank you


(Lukas Winkler) #2

Hi,

DNT is just a HTTP header the browser sends. And when Matomo get’s a request that has this header then it drops this request. This does not influence cookies in any way.

But there is also a Matomo Javascript feature _paq.push(["setDoNotTrack", true]); that tells Matomo to not even send the data to the server if DNT is enabled. I don’t know if the cookies are set before or after, but it might be worth a try to add it.


(Ben) #3

Thank you very much for this response, I will give it a go.


(Ben) #4

Hi Lukas,

This is already set to true, but thank you for the suggestion.


(Chris Tomlinson) #5

try something like

if (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes") {
    _paq.push(["disableCookies"]);
}

Cross-browser support might not be perfect so check out Navigator.doNotTrack - Web APIs | MDN and some real world tests to see if it works in the browsers you need it to - in any case, it might be better than nothing.