- When setting up your Analytics property, you can pick any domain. You could go with example.org, if you don't have one.
- There are multiple variants of Google Analytics scripts. You want to pick analytics.js: https://www.google-analytics.com/analytics.js
- Add the domain to your content security policy in the manifest
{ "content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'" }
- This code works. It's intended for a background/event page:
window.onload = ()=>{ window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA--', 'auto');