Sha256: a14994f751fb6dcde9b6141a4024bcfcb60a58d05384c77201f1725fc293df26

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module Analytical
  module Google
    class Api
      include Analytical::Base::Api

      def initialize(parent, options={})
        super
        @tracking_command_location = :body_prepend
      end

      def init_javascript(location)
        init_location(location) do
          js = <<-HTML
          <!-- Analytical Init: Google -->
          <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 googleAnalyticsTracker = _gat._getTracker("#{options[:key]}");
            googleAnalyticsTracker._initData();
            googleAnalyticsTracker._trackPageview();
          </script>
          HTML
          js
        end
      end

      def track(*args)
        "googleAnalyticsTracker._trackPageview(\"#{args.first}\");"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
analytical-1.3.0 lib/analytical/google.rb
analytical-1.2.0 lib/analytical/google.rb