forgetConsentGiven and opt-out iframe problem

Hello!

I am using the tracking script in my head as followed:
var _paq = window._paq || [];
// require user consent before processing data
_paq.push([‘requireConsent’]);
_paq.push([“setDocumentTitle”, document.domain + “/” + document.title]);

I ask users for consent and when they click on the button to refuse, I call the _paq.push([‘forgetConsentGiven’]); function in my footer.

This should work, because when I tested it, my visits were not being tracked in the dashboard.

My Problem is as followed: I use the opt-out iframe in my data privacy statement. But when I visit my site and refuse the tracking, the checkbox in the iframe is checked and it says there, that my visiting is being tracked. This should not be the case, since I refused the tracking in the first place.

Have I done something wrong?

Thank you for your help and have a great day!

Hi,

The optIn/optOut via Javascript and the OptOut iFrame work fundamentally different and independent from each other.

This is because of technical reasons: The iFrame runs on the Matomo domain and as websites can only set cookies on their own domain, it sets an opt-out cookie there. The Javascript runs on your website, so it sets the opt-out cookie there.

I’d recommend you to replace the iFrame with a Javascript-based one as explained here:
https://developer.matomo.org/guides/tracking-javascript-guide#optional-creating-a-custom-opt-out-form

The solution works perfectly! Thank you very much :slight_smile:

1 Like