开发者

Tracking Chrome extension events in Analytics

开发者 https://www.devze.com 2023-03-12 11:11 出处:网络
G开发者_如何学Coogle Chrome Extension documentation has some good information here: http://code.google.com/chrome/extensions/tut_analytics.html

G开发者_如何学Coogle Chrome Extension documentation has some good information here: http://code.google.com/chrome/extensions/tut_analytics.html

I put the analytics tracking code in my background.html file.

However I tried putting the _gaq.push call inside a script that runs on the page and got an error saying that the variable _gaq is not defined.

So I have to put onclick events in every element on the page I want to track and from there, call a function in background.html? Is there a better way to track events?


You can do this with chrome.extension.sendRequest in the content script and chrome.extension.onRequest.addListener in the background.html page. See here for more details: http://code.google.com/chrome/extensions/messaging.html. Also be sure your manifest.json is correct; I ran into problems when I had a hyphen character instead of an underscore.

0

精彩评论

暂无评论...
验证码 换一张
取 消