Sha256: 49970ee572eff8081375901da81bf53e776b4c8ad02dcc8fd3723839423b14c4

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

module Analytical
  module Modules
    class Reinvigorate
      include Analytical::Modules::Base

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

      def init_javascript(location)
        init_location(location) do
          js = <<-HTML
          <!-- Analytical Init: Reinvigorate -->
          <script type="text/javascript">
            document.write(unescape("%3Cscript src='" + (("https:" == document.location.protocol) ? "https://ssl-" : "http://")
            + "include.reinvigorate.net/re_.js' type='text/javascript'%3E%3C/script%3E"));
          </script>
          HTML
          js
        end
      end

      def identify(id, *args)
        data = args.first || {}
        "var re_name_tag = \"#{id}\";"
      end

      def context(data)
        return '' if data.blank?
        if data[:email]
          "var re_context_tag = \"mailto:#{data[:email]}\";"
        elsif data[:url]
          "var re_context_tag = \"http://#{data[:url]}\";"
        else
          "var re_context_tag = \"#{data.first.last}\";"
        end
      end

      def track(data, *args)
        "try {
          reinvigorate.track(\"#{options[:key]}\");
        } catch(err) {}"
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
analytical-3.0.12 lib/analytical/modules/reinvigorate.rb
analytical-3.0.11 lib/analytical/modules/reinvigorate.rb
analytical-3.0.9 lib/analytical/modules/reinvigorate.rb
analytical-3.0.8 lib/analytical/modules/reinvigorate.rb
analytical-3.0.7 lib/analytical/modules/reinvigorate.rb
analytical-3.0.6 lib/analytical/modules/reinvigorate.rb
gsiener-analytical-2.10.2 lib/analytical/modules/reinvigorate.rb