How to get a page’s Google Analytics tracking ID via a Chrome Extension?

I used to use[1][':trackingId']; a few months ago and it works well. But recently it’s not working and says getAll is not a function.

What should I do instead?

Google Analytics vs. Chrome Web Store Statistics Very Different

I recently released a chrome extension new tab, and I wanted to check the download/usage statistics.

I added both google analytics and checked the chrome web store stats. The values are extremely different. Here they are (for the same app):

web store

Here is my extension on the web store:

My question: why are these values so different? They are off by a factor of 10. Which one (if any) is correct, and is there some way I can know for sure?


Google Analytics Events for Chrome Browser Extension Not Firing

I am trying to get Google Analytics events to fire from a chrome browser extension. I have the following code in my content script to inject ga:

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-XXXXXXXX-Y', 'auto', 'myTracker');

ga('myTracker.send', 'event', 'test_category', 'test_action', 'test_label');

In my manifest.json, I added the following line:

"content_security_policy": "script-src 'self'; object-src 'self'",

The event does not seem to be triggering as it does not show up in my Google Analytics console. Does anybody know where I could be going wrong?

Thanks very much.

how to make gtag to work in chrome extension?

I’ve added gtag.js to my chrome extension but I don’t see anything on the nework, please tell me what I did wrong.

This is my CSP in manifest.json

   "content_security_policy": "script-src 'self'; object-src 'self'"

This is my index.html used by my extension (which replaces the user’s default tab)


Here’s how I trigger views and events

gtag('config', GATID, {
  page_path: path

gtag('event', binding_value.action, {
    event_category: binding_value.category,
    event_label: binding_value.label,
    value: binding_value.value

Although I followed every step, here’s what I have on the network : nothing.

Here’s the dataLayer var which proves my events are added to the queue but not triggered

  "0": "js",
  "1": "2018-04-24T21:02:54.881Z"
  "0": "config",
  "1": "UA-XXXXXXXXX-X",
  "2": {
   "checkProtocolTask": null,
   "custom_map": {
    "dimension5": "under 1.5 or failed"
  "0": "config",
  "1": "UA-XXXXXXXXX-X",
  "2": {
   "page_title": "Mesquite Flat Sand Dunes",
   "page_path": "/mesquite-flat-oleksandr-mokrohuz-small.jpg"
  "0": "event",
  "1": "click on reload",
  "2": {
   "event_category": "Image View"

What can the issue be here ?

Correct way of setting statistical dimensions (metric?) in Google Analytics

I have an extensions that offers many similar tools for a task. Users select which tools from the list they’d like to use, and I want to send info about which tools they used and which they didn’t.
As a result I want to make custom report with percentage for each tool:

tool1   tool2
 50%     38%   ... and so on

As I understand, I need to create custom metric for each tool, is that correct?
The question is — how can I make them “global”, so then I can make global report and see the percentage distribution, what value should I send in this case? Just 1 for “used” and 0 for “not used” or something different?
Currently I send data like that:

... set all additional dimensions ... 
ga("send", {
    hitType: "event",
    eventCategory: "Action Button",
    eventAction: "click",
    eventLabel: "Work"

How can I see total installs for my chrome extension in google analytics?

on which events do I need to configure google analytics to see the chrome extension settings?

How to intercept network calls with Chrome Devtools Protocol from command-line?

I’m trying to write a script that will find which Google Analytics tracking scripts are sending pageview hits on a certain page.

I.e. GET requests similar to this one:

Request URL:>m=G1uPABCVBVBN&z=118451129

My plan was to use Chrome Headless and use the DevTools protocol to exctract these requests as strings.

How would I format a command-line call to intercept network calls? I have tried reading the documentation but it’s way to convoluted for me to understand how I would actually design the “query”

Add Google Analytics to a Chrome Extension

In order to add google analytics to a chrome extension the official docs provide the following snippet:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);

(function() {   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;   ga.src = '';   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();

But google also recommends to migrate from ga.js to analytics.js.

ga.js is a legacy library. If you are starting a new implementation,
we recommend you use the latest version of this library, analytics.js.
For existing implementations, learn how to migrate from ga.js to

After following carefully the migration guide and upgrading the content security policy with the new script ( from to ), it simply didn’t work, without showing any error message.

Any suggestion welcome,

How to track events using GA in a chrome extension?

I am attempting to track events in my Chrome extension using Google Analytics. I have been able to install GA successfully because I see that there is an active user in GA’s real-time view.

However, I am trying to send an event on a page load and I’m not able to do so. I’m following the instructions here, but with no luck:

Here is my event:

window.addEventListener('load', trackButtonClick);

Here is my GA code in popup.js:

function trackButtonClick(e) {
  _gaq.push(['_trackEvent',, 'loaded']);

Any advice on how I can get the event to properly register? Also, how I would add a variable to the event trackButtonClick (for example, a text string)?

Google Analytics tracking isn’t working in chrome extension

I tried this method:

Google Analytics tracking in Chrome Extension’s background.html

as well as official tracking method for extension but it’s not working. i’m a newbie and i tried only 2 methods till now that i mentioned above but it’s not working i can’t track, nothing showing in analytics, is there any thing i’m wrong doing?