I am trying to integrate google analytics to a Chrome Extension (note that I also want to release it as a Edge and Firefox add-on) but I cannot get it to send any event. There is no specific error, just that the event then won't show up in my Google Analytics Dashboard.
In my manifest.json I do have
...
"content_security_policy": "script-src 'self' https://www.google-analytics.com https://www.googletagmanager.com/ object-src 'self'",
...
In my script I do:
// This basically allows to use gtag
import gtag, {install} from 'ga-gtag';
const ID = 'G-XXXXXXXX';
install(ID);
export function testTracking(){
gtag('event', 'test', {
category: 'xxx',
other_stuff: 'yyy',
checkProtocolTask: false,
page: '/extension_page/',
});
}
// at some point in my code, from either content/background/popup scripts
testTracking();
I tried to add checkProtocolTask and page after reading some other posts but it did not help. Not sure what I do wrong at this point. I noticed that there the events 'first_visit', 'scroll' and 'session_start' were fired once but not anymore since then.