Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pgilad
Last active June 22, 2016 22:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgilad/6823388 to your computer and use it in GitHub Desktop.
Save pgilad/6823388 to your computer and use it in GitHub Desktop.
Google Analytics ga.js for chrome extensions - snippit that doesn't report on development enviornment
//replace UA-XXXXXXXX-X *ONLY* with your real UA Account ID.
//DO not replace the UA-99999999-X with anything, as that is the point of this.
var _gaq = _gaq || [];
(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);
if (!chrome.runtime.getManifest().update_url) {
DEBUG && console.log('Setting up local analytics ID of UA-99999999-X');
_gaq.push(['_setAccount', 'UA-99999999-X'])
} else {
DEBUG && console.log('Setting up online analytics ID of UA-XXXXXXXX-X');
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment