Sha256: 4b537580b0c54493c539b54e96ad8d6e46b37cde50ddc61dfed69bfffac7d20a

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

module Analytical
  module Adwords
    class Api
      include Analytical::Base::Api

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

      def init_javascript(location)
        return ''
      end

      #
      # Define conversion events in analytical.yml like:
      #
      # adwords:
      #   'Some Event':
      #     id: 4444555555
      #     language: en
      #     format: 2
      #     color: ffffff
      #     label: xxxxxxxxxxxxxxxx
      #     value: 0
      #   'Another Event':
      #     id: 1111333333
      #     language: en
      #     format: 2
      #     color: ffffff
      #     label: yyyyyyyyyyyyyyyy
      #     value: 0
      #
      def event(name, *args)
        html = ''
        if conversion = options[name]
          html = <<-HTML
          <!-- Google Code for PPC Landing Page Conversion Page -->
          <script type="text/javascript">
            /* <![CDATA[ */
            var google_conversion_id = #{conversion[:id]};
            var google_conversion_language = "#{conversion[:language]}";
            var google_conversion_format = "#{conversion[:format]}";
            var google_conversion_color = "#{conversion[:color]}";
            var google_conversion_label = "#{conversion[:label]}";
            var google_conversion_value = #{conversion[:value]};
            /* ]]> */
          </script>
          <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script>
          <noscript>
            <div style="display:inline;">
            <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/#{conversion[:id]}/?label=#{conversion[:label]}&amp;guid=ON&amp;script=0"/>
            </div>
          </noscript>
          HTML
        end
        html
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
analytical-0.14.0 lib/analytical/adwords.rb