Tracking the Page View and Events in a GDPR friendly way


I am trying to track a website with Matomo Tag Manager but I am facing an important issue. Let me explain the situation.

My website has an external cookie banner. When cookies are accepted, it sends an event “consent_cookie_manager” with a variable “DL - Matomo” set on “1”. If the user refuses cookies, then 'DL - Matomo" will be set on “0”. Of course, the Datalayer is dynamic based on the user’s consent, so if users refuse and then change their consent to accept all cookies, a second “consent_cookie_manager” will be sent and the “DL - matomo” variable will pass from “0” to “1”.

My configuration for the pageview :

  • Matomo analytics pageview-based tag
  • Trigger based on the event “consent_cookie_manager” when “DL - Matomo” is set on “1”.
  • Tag set on “illimited” for the test

1/ When I try to set up an event or my pageview, my issue is the following :

  • I land on the website for the first time, no DL event is sent while awaiting for user’s consent. So my pageview does not trigger. (Normal state)
  • I accept the cookies, the datalayer “consent_cookie_manager” is sent and the “DL - Matomo” variable is set on “1” but Matomo does not see the datalayer that has been sent so my pageview is not triggering.
  • The pageview is sent only when refreshing the page as the datalayer is present when the page loads.

Could you please help me to fix this ?

2 / The pageview does not trigger when updating consent :

  • If I refuse the cookies, a first “consent_cookie_manager” is sent and the “DL - Matomo” is set on “0”
  • I change my consent to set it on “true”
  • A new datalayer “consent_cookie_manager” is sent and the “DL - Matomo” goes from “0” to “1” → this does not work because Matomo does only the first datalayer event and not the second

Could you please help me to fix this ?

Many thanks for your help :slight_smile:

UP to get some help on this matter. :slight_smile: