I'm trying to track a chrome extension on Google Analytics.
It looks like it's configured correctly but I can't see the data on the dashboard. Not sure if it's a delay, if it's being ignored because I'm running the extension on development mode or if I need to configure something else.
I'm using the following code:
const gaScript = document.createElement('script');
gaScript.type = 'text/javascript';
gaScript.async = true;
gaScript.src = 'https://ssl.google-analytics.com/analytics.js';
gaScript.onload = function() {
ga.l = +new Date;
ga('create', 'MY_CODE', 'auto');
ga('set', 'checkProtocolTask', null); // Disables file protocol checking.
ga('send', 'pageview');
}
const s = document.getElementsByTagName('script')[0];
s.parentNode?.insertBefore(gaScript, s);
When I check the background console, on the tab "network" I can see:
- a request for "analytics.js" and I can see the file is being loaded correctly
- a request for a URL "collect?v=..." which seems to indicate the extension is sending the data correctly to google servers. When I inspect this URL I can see it's sending MY_CODE as a parameter for the tracking id
But I still can't see ana logged data on the analytics dashboard. Any idea why is it happening?
Update:
Thanks to Michele I was able to understand the problem. Google created a new form of tracking: Global Analytics and the code is different from the standard Universal Analytics.
Whoever creates an analytics project today will get the Global Analytics by default. I studied it and I think the standard works better for extensions for now. I would wait Google update their documentation to include this case to start using it
