This matomo tracker js code is placed before </body>, but eaven in the <head>, the opt-out status is not saved correctly:
var _paq = window._paq = window._paq || ;
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script');
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
Strangely enough, the cookie “mtm_consent_removed” is sometimes set when the page is opened, even though the opt-out form checkbox is checked. After a page reload, the opt-out form checkbox is not active and the cookie is gone. Shouldn’t it be the other way around? After another reload of the page, the opt-out form checkbox is set again and the cookie “mtm_consent_removed” is also there again. If the checkbox is deactivated by clicking on it, the cookie is set correctly. But if i reload the page, the cookie is gone. I suspect there are errors in the script that controls the new opt-out form.
Probably, i am not sure. Before this change or before matomo 4.12.0 i used the legacy iframe opt-out with the “custom opt-out” plugin.
Another issue with new opt-out js code is, if you use no consent tool (because of disabled tracking cookies) and use the default standalone js code from the admin opt-out ui, the checkbox of the opt-out form is always uncheckt by default, because no consent cookie is found. This is wrong in my eyes/usecase, because matomo tracking does not need consent by default. I have added an if statement to the function hasConsent to check if both cookies are missing and then return true.