Sha256: 549f0ad15fe45fbe0a942ebbbe91a5f6eeb0446ddbe4f5b0c576e0bc1880daa8

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

module Analytical
  module Modules
    class Totango
      include Analytical::Modules::Base

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

      def init_javascript(location)
        init_location(location) do
          js = <<-HTML
          <!-- Analytical Init: Totango -->
          <!-- step 1: include the loader script -->
          <script src='//s3.amazonaws.com/totango-cdn/sdr.js'></script>

          <!-- step 2: initialize tracking  -->
          <script type="text/javascript">
          try {
          	var tracker = new __sdr(\"#{options[:key]}\");
          } catch (err) {
          	// uncomment the alert below for debugging only
          	// alert ("Totango tracking code load failure, tracking will be ignored");
          	quite = function () {};
          	var tracker = {
          		track: quite,
          		identify: quite
          	};
          }
          </script>
          HTML
          js
        end
      end

      def identify(id, *args)
        data = args.first || {}
        "tracker.identify(\"#{data[:email]}\",\"#{data[:organization]}\");"
      end

      def event(name, *args)
        data = args.first || {}
        "tracker.track(\"#{name}\", \"#{data[:module]}\");"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gsiener-analytical-2.10.0 lib/analytical/modules/totango.rb