3rd party cookies work less and less and eventually won't be available anymore. Kind of related post https://matomo.org/blog/2020/02/new-cookie-behaviour-in-browsers-may-cause-regressions/ For the opt in to work we therefore need a different way and set first party cookies.
Matomo for WordPress already doesn't use the opt out iframe anymore and sets first party cookies. In On-Premise as part of https://github.com/matomo-org/matomo/issues/12767 we already added the support of
postMessages to set first party cookies when possible. This however currently only works in some cases (eg when the tracking code is embedded on the same page and both opt out and tracking code use the same Matomo domain).
Or maybe we would need to offer a new way of embedding the opt out without any iframe. This would likely require loading another JS and some configuration to customise it and for Matomo to know where to place it (unless this is all stored in a JS file and the user can configure multiple different JS opt out files).
In theory something like this might work and be user-friendly, right?
<div id="opt-out"></div> <script data-id="opt-out" src="https://matomo.example/optout.js"></script>
Only issue is maybe localisation as this might bloat the js file quite a bit.
The current iframe opt out, also has few other options to customise colors etc:
<iframe style="border: 0; height: 200px; width: 600px;" src="/index.php?module=CoreAdminHome&action=optOut&language=en&backgroundColor=&fontColor=&fontSize=&fontFamily=" ></iframe>
We would provide the same options for this. For example using data attributes like
We also offer options to customise cookie domain, cookie same site, cookie secure, cookie path, cookie name prefix.
The rendered content should look and function otherwise the same as before. However, the cookie is set on the site that you're on and not on the Matomo instance.