ngx-matomo
ngx-matomo copied to clipboard
How to init matomo _after_ user has accepted terms?
We've an issue because we don't want to initialize Matomo, before user has accepted the terms of service. How would we do this?
For now it looks like that init is causing that matomo is loaded before user has accepted this.
I would start by adding requireConsent: true to the MatomoConfig and then, once your user has accepted the terms of services, I would call this.matomoTracker.setConsentGiven() which will everything to your Matomo instance.
Actually that didn't do the trick for me - I needed to track that state myself to get all working as expected.
If you'd like to check the "standard" behavior, then:
- Clone this repo
- Build ngx-matomo :
npm run build:ngx-matomo:prod - Run the demo app :
npm run test
You'll see that in this app, no tracking occurs before user consent is provided.
If your use case required something different, I'm willing to have a look at it!
Yeah, the main reason is that we need to use this plugin - https://plugins.matomo.org/AjaxOptOut - and if we do that your.piwik/index.php?module=API&method=AjaxOptOut.isTracked request tracking is started.
So I just resolved this by storing this tracking status to local storage and if it's accepted then I do that query otherwise not - simple solution after some testing.
Thanks for the information. Once I nicely integrate MediaTracking and Form Tracking, I'll check how to provide a better way to interact with plugins.