Is it possible to deactive tracking from frontend

Dear Piwik Community,

I know that there is a plugin to disable tracking on server site just by setting a checkmark. Still, the piwik events are fired from the frontend, but not processed in backend.

Does anyone know a solution where it is possible to prevent the events to be fired from javascript code without going through the project code and removing any piwik related code?

Thanks for any replay in advance

BR
Alex

I am also looking forward for this feature.

Background:
For the different environments we want to be as near as possble to production, so to execute full customized Matomo and Matomo client code, but not sending tracking requests requests all the time e.g. in certain automated tests, at the same time to allow users to store consent cookie for QA, so they dont need to accept it again and again.

Hi,

The Matomo tracking code is just normal JavaScript. So if you don’t want to send tracking requests on the frontend, simply don’t call _paq.push(['trackPageView']); in these cases. (same for tracking events, etc.)

So you say, without any code of trackPageView we should be fine, so Matomo will send 0 information, no request at all on any features, such as form tracking, session recording page view tracking, events?

We have several applications. What would fit our need is somethink like “requireConsent” cookie

Hi,

That I wouldn’t say so sure. If you e.g. call _paq.push(['trackEvent', 'Contact', 'Email Link Click', 'name@example.com']); somewhere in your site then this will still make a request as it is independent of trackPageView.

So if you want Matomo to not be at all on the site, you need to wrap the whole tracking code in a Javascript if and only execute it if you want it to do something.

You will probably still need the var _paq = window._paq = window._paq || []; line as otherwise your _paq.push functions will throw an error.

Of course if you need something like “requireConsent”, you can simply use requireConsent as explained on https://developer.matomo.org/guides/tracking-consent