Google Analytics Rails Plugin w/ new tracking code
Posted on February 10th, 2008 by thetacom
If you using the Google Analytics plugin, but want to use the new tracking code. Then replace the self.included(base) definition in “google_analytics/lib/google_analytics.rb” with this one:
def self.included(base) #nodoc#
base.class_eval do
@@no_analytics_key_message = 'Add your analytics key with code like GoogleAnalyticsHelper.analytics_key = "ZZ-NNNNNN-N"'
@@analytics_key = nil
@@analytics_base = <<-EOT
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("%key%");
pageTracker._initData();
pageTracker._trackPageview();
</script>
EOT
end
end
Tags: analytics, google, google_analytics_plugin, plugin, rails
Related posts
Filed under: RoR Plugins, Ruby on Rails






Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks