Created
November 18, 2014 06:46
-
-
Save huobazi/0cb28c2663ef2233583e to your computer and use it in GitHub Desktop.
app/assets/javascripts/google_analytics.js.erb:
This file contains 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
<% if Rails.env == 'production' %> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXXXX-XX']); | |
_gaq.push(['_trackPageview']); | |
ga_src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
$.externalScript(ga_src).done(function(script, textStatus) { | |
console.log('Script loading: ' + textStatus ); | |
if (typeof _gat != 'undefined') { | |
console.log('Okay. GA file loaded.'); | |
} | |
else | |
{ | |
console.log('Problem. GA file not loaded.'); | |
} | |
}); | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment