How to enable Heatmap and Session recording on consent?
Have you ever considered the feasibility of enabling the Heatmap and Session Recording feature based on user consent? If this idea has crossed your mind, rest assured that it’s indeed possible. Within Matomo, you can activate this feature when a user explicitly requests and consents to it.
Please follow these instructions:
- To deactivate Heatmaps and Session Recording, please add
_paq.push(['HeatmapSessionRecording::disable']);
in your tracking code. - To require user cookie consent before storing and using any cookies, add
_paq.push(['requireCookieConsent']);
- To remember cookie consent was given for all subsequent page views and visits, add
_paq.push(['rememberCookieConsentGiven']);
. - Once the user has given consent to process their data use
_paq.push(['setConsentGiven']);
and to activate heatmaps and session recording by inserting the script_paq.push(['HeatmapSessionRecording::enable']);
.
If a visitor chooses to withdraw their consent at a later point, you may need to remove the cookie consent. You can do this by using _paq.push(['forgetCookieConsentGiven']);
. In such a case, do remember to disable the Heatmap and Session Recording feature, as explained in Step 1.