Sha256: 0b27958b70d885f4b571349b3026c8309f5315a106b07c716c656f5386d0b9fb

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

class Rack::Tracker::GoogleTagManager < Rack::Tracker::Handler

  class Push < OpenStruct
    def write
      to_h.to_json
    end
  end

  # It is strongly recommended to put the google_tag_manager snippet only in the body tag
  # https://developers.google.com/tag-manager/quickstart
  self.position = :body

  def container
    options[:container].respond_to?(:call) ? options[:container].call(env) : options[:container]
  end

  def render
    Tilt.new( File.join( File.dirname(__FILE__), 'template', 'google_tag_manager.erb') ).render(self)
  end

  def self.track(name, *event)
    { name.to_s => [event.last.merge('class_name' => event.first.to_s.capitalize)] }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-tracker-1.2.0 lib/rack/tracker/google_tag_manager/google_tag_manager.rb
rack-tracker-1.1.0 lib/rack/tracker/google_tag_manager/google_tag_manager.rb