Take the 2-minute tour ×

I have created an extension for Chrome that uses a content script to interact with certain pages, and now I want to add Google Analytics tracking. I have copied the standard extension code from google (putting my correct account id) and added the required permissions in the manifest:

 var _gaq = _gaq || [];

(function() {

When running in the background page, this code works great, but it doesn't help me much as it will run just once when the browser starts. I want it to run whenever my extension interacts with a page, so I put it on the content script, but it doesn't seem to do anything. I don't see any error on the log, and the google analytics debugger doesn't seem to be aware of my tracking code at all.

share|improve this question
possible duplicate of Chrome extension adding external javascript to current page's html –  Rob W Jul 3 '13 at 14:58
Fantastic! the solution in stackoverflow.com/questions/10285886/… works! How bad is it to include ga.js in the extension itself? Is it likely to break? The extension updates automatically once I publish a new version. Is it –  drorw Jul 3 '13 at 21:03

Your Answer



Browse other questions tagged or ask your own question.