Last active
June 22, 2016 22:15
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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