Search code examples
cookiesmatomocontao

How to use Do-Not-Track-Me cookie to disable tracking


I am using cookiebar extension for cookie management of my contao site. For disabling piwik , can I use Do-Not-Track-Me .Then,How can I use it? The google analytics can be disabled like

window['ga-disable-<?= $GoogleAnalyticsId ?>'] = !!localStorage.getItem('COOKIEBAR_ANALYTICS');

Solution

  • This has nothing to do with the "Do-Not-Track" setting of the browser. The cookiebar extension uses its own setting in the local storage of the browser.

    You can simply wrap your Matomo tracking code with

    if (!localStorage.getItem('COOKIEBAR_ANALYTICS')) {
        …
    }
    

    for example.

    I am not sure what the advantage of using window['ga-disable-…'] is, instead of a simple if () {}.