-
Implementing Google Analytics 4 within a Chrome Extension using Manifest V3
Let me put it like this.
So, here’s the real talk =>
- Alright, looks like you can’t really import scripts from links when you’re in a chrome extension’s background scripts or content scripts, basically anywhere inside a new HTML page or a pop-up HTML. And you’re like, “so what do I got to do?”, well I’m about to show you =>
Remember how you’d use this code snippet?
<html lang="en"> <head> <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX" ></script> </html>
Well, you’d actually want to do this instead:
<html lang="en"> <head> <script src="./googleAnalytics.js"></script> <script src="./googleAnalyticsStarter.js"></script> </head> </html>
What’s the idea? Well, instead of pulling directly from the site, bring what you need into your own extension file, and reference them from there.
Log in to reply.