Support » Plugin: Tracking code for Matomo, by Sergio Santos » Option for Do Not Track

  • It should be useful to add an option in the backend to support the Do Not Track browser’s feature.

    I usally do something like this:

    function do_not_track() {
    if( ! function_exists('apache_request_headers') ) {
    return false;
    $h = apache_request_headers();
    return isset( $h['DNT'] ) && $h['DNT'] === '1';

    if( ! do_not_track() ) {
    echo print_piwik();

    For more informations:

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, @reyboz!

    I agree, that is a useful option, but have you see this?:


    @sergiorcs IMHO stripping the whole tracker is a better approach 🙂

    Hi, @reyboz!

    Sorry for the delay. I’ve been giving this some thought.

    I agree, it would be much better not to send data instead of sending data that will be rejected. I would also save a few resources and make the pages look “less suspicious”.

    However, at first glance, your solution seems like it would only work on Apache servers. While it’s true that Apache currently powers the vast majority of hosts, not all of them use it. NGINX, for example, is growing in popularity – so much so, that uses it. And I think it is also possible to install WP on IIS (which also powers a considerable percentage of hosts).

    If i were to include a Do Not Track feature on my plugin, i would like it to A) be optional (imposing stuff on users isn’t cool) and i would like it to B) work properly for everyone (or as close to that as possible). Part A would be fairly easy to take care of, of course, but i’m not so sure about B.

    Also, let’s consider this: if someone sets Piwik to ignore the Do Not Track option, and then enables it on the site, what would the expected result be? I know it sounds silly, but sillier things have happened before…

    I do appreciate your suggestion and contribution – really, thank you! – but for now i think it’s better to just keep things simple. And hey, if you’re keen on adding that option to the plugin, you can always fork it. (Just don’t forget to mention the original one, please.)

    Kind regards,

    @sergiorcs Now I see that also it can be used the following:

    return $_SERVER['HTTP_DNT'] && $_SERVER['HTTP_DNT'] === '1';

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Option for Do Not Track’ is closed to new replies.