Created
March 13, 2011 03:51
-
-
Save xwmx/867847 to your computer and use it in GitHub Desktop.
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
module GoogleAnalyticsHelper | |
def google_analytics_for(account, domain) | |
unless account.blank? | |
<<-ANALYTICS | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', '#{account}']); | |
_gaq.push(['_setDomainName', '#{domain}']); | |
_gaq.push(['_trackPageview']); | |
(function() { | |
var ga = document.createElement('script'); | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : | |
'http://www') + '.google-analytics.com/ga.js'; | |
ga.setAttribute('async', 'true'); | |
document.documentElement.firstChild.appendChild(ga); | |
})(); | |
</script> | |
ANALYTICS | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment