Angular load/unload patterning

Hi there,

I’m looking for some guidance regarding patterns to use for loading/unloading Piwik in our Angular SPAs. For reference, I’ve consumed the documentation here: @piwikpro/ngx-piwik-pro - npm

Our applications retain user preferences using localstorage, including the user’s consent preference. We display a Piwik consent modal depending on the value(or lack of value) of the user’s consent preference.

You can imagine a scenario where on first launch we do not have the user’s tracking consent, so we must load our SPA without NgxPiwikProModule in Angular’s AppModule. If consent is given at a later time, the entire Application must be re-bootstrapped because NgxPiwikProModule can only be provided during bootstrapping. Similarly, if the user withdraws consent at a later time, the application must be re-bootstrapped to remove NgxPiwikProModule from Angular’s root module pool.

This is clunky. Surely this must be an issue for others using Piwik’s Angular tooling?

What is Piwik’s expected patterning for an Angular application loading and unloading these modules when the user’s consent is absent (first run) or changes later?

Hi @CCTipher ,

I would like to help with your problem, however, before we get to the programming issues. Let’s try to consider whether it is definitely necessary to skip loading the Piwik PRO module altogether.

Why? You may find it helpful to take a look at this article:

Our tool uses anonymised data by default until someone approves our consent. You can rest assured that no personal user data will be passed on until they have given their consent. We comply with regulations worldwide, like GDPR or the ePrivacy Regulation.

For this reason, it should not be necessary to remove the module from the application.

At the same time, if you would like to completely stop the sending of data until consent has been given, you can do so in the settings of the Piwik PRO website.

Go to:

Administration > Sites & apps > [select website] > Privacy tab > Ask visitors for consent [enable] > Consent settings [View] > Collect anonymous data from non-consenting visitors [disable]
this option should be disabled.

Let us know if these solutions are sufficient for you.

It will be my pleasure if I can help you in some way.