Custom opt-out form - not working in Safari


I build a custom opt-out form following the example in the documentation. In Chorome it works well most of the time. Just on some reloads the checkbox text won’t display because _paq is not defined. But in Safari, the checkbox text is missing on every page load. The console logs an error that the variable _paq can’t be found. Even when the checkbox gets checked the, once the page gets reloaded the checkbox is unchecked again. The consent removed cookie also never gets set. I couldn’t find anyone in the forum reporting this behaviour so I’m wondering if I’m doing something wrong?


Maybe is it related to some scripts not loaded when the custom opt-out is running?
Is it possible to add your code, not in the DOMContentLoaded event but in the matomo script load event? (in your code, add the load event listener to the g variable)? (not tested)

@heurteph-ei thanks for you input! I will certainly give it a try!