Search code examples
google-chromegoogle-chrome-extensionanalytics

Chrome extension use report


I have written a chrome extension which I just published to chrome store. I'd like to know all the numbers associated with it. This includes number of installs/number of active users/user activity etc.

Where do I get these numbers from? according to this question there is no way to see the total number of installs: How can I see the number of total installs for my chrome extension?

More importantly is there a way for me to setup Weekly/Monthly emails to get these numbers directly to my inbox?


Solution

  • There's not an official way to do this. Google doesn't provide you detailed stats for your extensions, so if you want to know the details, you should use Analytics.

    Follow the tutorial here to set up your Analytics account.

    To know the number of people that installs your extension you'll need to set up an Analytics account and link it to your extension, then you can use the chrome.runtime.onInstalled.addListener method to listen to the installation and send a _trackEvent to your Analytics account.

    So in your background.js you'll do something like this:

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
    // where UA-XXXXXXXX-X is your Analytics Account user number
    
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = 'https://ssl.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    
    // now add a listener to the onInstalled event:
    chrome.runtime.onInstalled.addListener(function() {
        _gaq.push(["_trackEvent", "Installation"]);
    });
    

    You can set any combination of "category", "action", "label" after the first "_trackEvent" string calling _gaq.push(["_trackEvent", ...]). Now, every time a user installs the extension, you'll see the number of "Installation" events increase in your Analytics account.