Yet another thread on the compatibility of Chrome Extensions with other Google Ecosystem Services, sorry...
We are trying to migrate our Chrome Extensions from Universal Analytics -> GA4 in preparation for the sunset of Universal Analytics next year. It doesn't appear to be ready. Here are our findings so far:
1) gtag.js cannot be used inside a service worker. It requires a window/document for all of the automatic telemetry capture & dynamic injection of scripts
2) Firebase Analytics is not supported inside a service worker
3) Measurement Protocol v2 functions but it is unable to capture any useful information. For example, it has no method for capturing Browser, OS, Language, Location, Demographic or Screen Views.
4) Content Scripts can't (shouldn't) be used for gtag.js. gtag dynamically injects <script> tags into the page, breaking out of the content script sandbox and potentially causing conflicts with existing gtag setups on the page.
Launching a tab/window for gtag.js to access the window/document is clearly not an option here, as that presents the user with terrible UX.
Any suggestions/thoughts welcomed...
Thanks,