AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

No logs are sent from a Chrome extension environment #312

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Name of affected component: Tracking Code (Javascript / analytics.js)

Issue summary:
When loaded inside a Chrome extension background page, analytics.js does not 
work. No console errors are raised, it just doesn't send events.

I loaded our extension's background page in debug mode using the Google 
Analytics debugger extension, and it looks like the Javascript loads fine but 
the document protocol is being rejected:

---
Registered new plugin: "linker" analytics_debug.js:5
Creating new tracker: t0 analytics_debug.js:5
Unallowed document protocol. Aborting hit. analytics_debug.js:5

---

URL of the page exhibiting the issue:
chrome-extension://ccajiafiihhhdifichejdhkfmcapbbmi/html/background.html

Steps to reproduce issue:
1. Create a Chrome extension and include the analytics.js loading script within 
the extension's background page
2. Try to send events.

Expected output:
Events are sent to Google Analytics

Actual results:
No events are sent.

Notes:

It looks like the fix here would be simple: in the code the URL seems to be 
tested against "http:" and "https:" to identify a valid protocol. Maybe 
"chrome-extension" could be added here to get this working properly.

Original issue reported on code.google.com by gjugg...@gmail.com on 20 Jun 2013 at 1:54

GoogleCodeExporter commented 9 years ago
Note: the term 'events' used by the original reporter might be ambiguous: Not 
only events but also pageviews do not work. 

Original comment by ama...@google.com on 2 Jul 2013 at 3:21

GoogleCodeExporter commented 9 years ago
This fixes it:

// ga('create', ....
ga('set', 'checkProtocolTask', function(){}); // Overrides the function that 
checks 
                                              // for protocol name

Disclaimer: Someone else told me. I don't deserve credit for this :)

Original comment by alfo...@gmail.com on 2 Jul 2013 at 10:08

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by dspatti...@google.com on 24 Jun 2014 at 11:33

GoogleCodeExporter commented 9 years ago
@dspatti, could you tell us why the issue was marked as fixed?

Original comment by bogdanvi...@gmail.com on 15 Sep 2014 at 9:32

GoogleCodeExporter commented 9 years ago
Hello! Ran into this yesterday and took me a couple hours to figure out. Would 
love to see this fixed too. :-)

Original comment by l...@google.com on 18 Sep 2014 at 1:08

GoogleCodeExporter commented 9 years ago
There is official document on this issue.
here:
https://developers.google.com/analytics/devguides/collection/analyticsjs/tasks

just put
ga('set', 'checkProtocolTask', null); // Disable file protocol checking.
after create the analytic.

In case of using analytics in an iframe on background page.
I opened another issue here:
https://code.google.com/p/analytics-issues/issues/detail?id=494

Original comment by sarun...@gmail.com on 18 Sep 2014 at 1:55