title: Accessing Google Analytics window._gaq from Chrome Extension
body: <p>I'm writing a chrome extension, mostly for learning purpose which will show me the Google analytics tracking id (UA-xxxxxx-x) if Google Analytics is installed.</p>
  
  <p>I understand that I need to use sendRequest to a content script in the page to retrieve information, and have successfully implemented that functionality </p>
  
  <pre><code>chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
      // analytics request check GA and send back
      if(request.requestDetail == "analytics") {
  
      console.log(window._gaq);
      console.log(window._gaq._getAsyncTracker()._getAccount());
  
      // unknown response, send back nothing!
      } else {
          sendResponse({}); 
      }
  });
  </code></pre>
  
  <p>The listener is receiving the request, Google Analytics is definately installed on the webpage I'm testing, window._gaq and window._gaq._getAsyncTracker()._getAccount() are both accessible via the console and returns what I expect.</p>
  
  <p><strong>Why is window._gaq undefined when accessing via the listener? How should I access it from a chrome extension?</strong></p>
  
  <p>I've got an idea that there is a security reason for this so have also tried modifying the manifest to include the below but still no luck</p>
  
  <pre><code>"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
  </code></pre>
  
  <p>I suppose a secondary question would be: </p>
  
  <p>Is what I'm trying to achieve possible in the manner I am using (I have managed to get a similar result using regex matching on the contents of the page, but would like to access the objects directly)</p>