Hoe IP-adressen Google Analytics anonimiseren in 2021 op Discourse?

The above is correct (of course change your UA ID). Extra step that’s needed is: go to your admin settings and search for content security policy script src.

There add https://www.google-analytics.com/analytics.js, then it works.