Disable any tracking after changing to NOT consent with custom consent form

Im trying to disable any tracking whatsoever when user do NOT consent while having custom consent system. I need to have full control of tracking, full - meaning no tracking at all even anonymous data, pings etc. when user did NOT consent. I also want to have option to change decision any time!

Im having SPA application.
Sending events manualy (want to have full control).

My configuration:




In general GoogleAnalytics or Matomo have this easy to control simple flag which you set and all tracking is disabled. Im looking for something like that with no success.
Matomo way: _paq.push(['rememberConsentGiven', ...]); / _paq.push(['forgetConsentGiven', ...]);
GoogleAnalytics way: window[ga-disable-${trackingId}] = false;

So I followed some custom consent form guidelines and read dev documentation.

Implemented how it should be according to docs as I understood it.
Setting at start: ppms.cm.api('setInitialComplianceSettings', { consents: ['analytics']});
Then when user makes action to accept / decline consents OR user already did it before (flag from BE response): ppms.cm.api('setComplianceSettings', { consents: { analytics: { status: consentValue ? 1 : 0 } } });
I even check if its set in cookies / storage and calling ‘getComplianceSettings’ command, every source shows its changed properly.

Everything is working properly at start.
Case accepted: ppms.js script is downloaded and some events are send in network and are visible on Tracker debugger.
Case declined: ppms.js script is NOT downloaded and no events are send in any way.

But when user changes mind and goes to change what was chosen before, then it seems like its not working as it should.
Case accepted → declined: pings are sent anyway unless you change “Count session time precisly” (would be nice to have those pings when accepted but not when declined), all manually triggered commands like trackPageView still sending events to Piwik system (can see them on Tracker debugger and browser’s network), I could make manual condition to not send any events if internal consent flag is false, but how can I be sure if something else would be send automatically which I didnt configured or there are some bugs or other unpredictable things (risk of breaking laws)
Case declined → accepted: ppms.js script is downloaded, and seems like everything works as it should
Case accepted → declined → accepted: same as above but getting error

ppms.js conflict
ppms.js:12 Matomo javascript tracker or Piwik PRO javascript tracker was already initiated on this page. Please check the tracker setup. Matomo conflict can be resolved using these instructions: https://help.piwik.pro/support/questions/can-i-use-piwik-pro-and-matomo-at-the-same-time/.

I do not use Matomo, its happening everytime I use command “setComplianceSettings”, with “accepted” payload (ppms.js script is downloaded again).

Seems like “setComplianceSettings” might be one use command (you only set it once and should not do it twice). So how can I change consent to false anytime with custom consent form? I saw opt-out form, but not custom one, so I assumed my custom form is enough, and I just have to use “setComplianceSettings” again (did not see any info about this command to be invoked only once per application life).

To summarize:

  1. How to properly change consent if its been already set before with CUSTOM consent form (both ways)?
  2. If using “setComplianceSettings” command multiple times with different payload is proper way, then what about this conflict ppms.js error?
  3. How to have “Count session time precisly” turned on when user consent but not having pings when user did not consent? manual heartbeat? (unless Im doing it wrong and it should be blocked when consent is declined after agreeing to it)
  4. Is there disable flag like GA or Matomo has?

Hi.

all manually triggered commands like trackPageView still sending events to Piwik system (can see them on Tracker debugger and browser’s network), I could make manual condition to not send any events if internal consent flag is false, but how can I be sure if something else would be send automatically which I didnt configured or there are some bugs or other unpredictable things (risk of breaking laws)

If you want to set up virtual page views manually, I’d suggest doing it via our Tag Manager. In general, we rely heavily on the Tag Manager when it comes to firing tags and taking into account consent choices. If you need full control, I suggest firing the page views (and other important events) via dataLayer pushes. Those pushes can be then intercepted via Tag Manager tag with proper consent type set.

As for other described issues - does full page refresh fix mentioned problems?

Hello.
I have played with PiwikPro more, and it seems like consents are working for tags.

(1) It seems like _paq.push commands are avoiding consent logic (consent dont have any effect on direct _paq commands), is it true and intended?

(2) Is there some kind of flag or command that entirely turns off PiwikPro scripts?

As for other described issues - does full page refresh fix mentioned problems?

Refreshing page (F5) just initialize everything again so basically a restart.
Everytime I send setComplianceSettings with true and compliance settings were in state non-true - ppms.js script is downloaded, so if I send setComplianceSettings more than once from non-true state to true, this error occurs (ppms.js script “JavaScript tracking client” is downloaded again - looks like something that should not happen, this script is trying to init trackers again, dont know yet why its downloaded again). From true state to true state there is no error.
By true and non-true, I mean: true = 1, non-true=-1 or 0. Btw. I did not see any problems when this error occurs, but its concerning and better to not have it (might not see everything that should or should not happen).

piwik_ppms_x2

(3) Can you confirm, that using setComplianceSettings multiple times on SPA and CUSTOM consent forms is the proper way to switch between consenting and not consenting?

Let me first answer your questions from the previous message.

  1. How to properly change consent if its been already set before with CUSTOM consent form (both ways)?

The way you’re doing it is fine.

  1. If using “setComplianceSettings” command multiple times with different payload is proper way, then what about this conflict ppms.js error?

It happens because changing consent type from rejected to accepted always fires all tag manager tags with given consent type assigned. This is a rather rare case and mentioned error doesn’t break the product. It simply clutters the console. We could think about a better message here or changing the error into warning.

  1. How to have “Count session time precisly” turned on when user consent but not having pings when user did not consent? manual heartbeat? (unless Im doing it wrong and it should be blocked when consent is declined after agreeing to it)

Calling _paq.push(["disableHeartBeatTimer"]); should do the trick. I just tested it and for some reason it doesn’t work. I’ll let the product team check what’s wrong.

  1. Is there disable flag like GA or Matomo has?

No, since all consent-related logic is handled by the tag manager.