We've been working on integrating Google Analytics into our Chrome extension, and here are the steps we've taken:
We updated our manifest.json
with the following line:
"Content-Security-Policy": "default-src 'self'; script-src 'nonce-4AEemGb0xJptoIGFP3Nd'",
Then, in our index.html
:
<head>
<meta charset="utf-8">
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'XXXXX', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js' nonce="4AEemGb0xJptoIGFP3Nd"></script>
<!-- End Google Analytics -->
</head>
We attempted using hash, nonce, and unsafe inline, but encountered the same error message in all cases:
https://i.sstatic.net/PeUbW.png
At this point, I'm running out of ideas.