Google Analytics Rails Plugin w/ new tracking code

No Gravatar

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: , , , ,

Related posts

Trackbacks

close Reblog this comment
blog comments powered by Disqus