webfactory / piwik-bundle

Symfony Bundle with twig-function for the Matomo (fka Piwik) tracking code
MIT License
39 stars 16 forks source link

Fix "setDoNotTrack" handling #46

Closed mpdude closed 1 year ago

mpdude commented 1 year ago

The setDoNotTrack configuration value has to be pushed to the _paqs before the trackPageView setting. trackPageView seems to trigger the actual logging request when it is being processed.

With the old state of the code, setDoNotTrack was set too late and never became effective. A request to the Matomo server would be sent in any case, relying on the server-side "do not track" privacy feature to be enabled.

This change adds a new enable_do_not_track configuration setting which defaults to true.

When you set it to false, the setDoNotTrack command will not be used. You can push it to the _paq array yourself, possibly depending on client-side logic. But remember: It has to be in the _paq array before the trackPageView entry.