Sha256: 8e4fb2d56fc994b8690caba707d2e03c217ce9c06b650f8e5858bfec7e24abc1

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Analytical
  module Modules
    class Google
      include Analytical::Modules::Base

      def initialize(options={})
        super
        @tracking_command_location = :head_append
      end

      def init_javascript(location)
        init_location(location) do
          js = <<-HTML
          <!-- Analytical Init: Google -->
          <script type="text/javascript">
            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', '#{options[:key]}'], ['_setDomainName', '#{options[:domain]}'], ['_trackPageview']);
            (function() {
              var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
              ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
              var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();
          </script>
          HTML
          js
        end
      end

      def track(*args)
        "_gaq.push(['_trackPageview'#{args.empty? ? ']' : ', "' + args.first + '"]'});"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
analytical-2.7.2 lib/analytical/modules/google.rb
analytical-2.7.1 lib/analytical/modules/google.rb
analytical-2.7.0 lib/analytical/modules/google.rb