Sha256: 78f979ff8ed432c0d37b41b27c89053a866ba53bd8fce72d299fe0f0a56d317e
Contents?: true
Size: 831 Bytes
Versions: 6
Compression:
Stored size: 831 Bytes
Contents
class Rack::Tracker::GoogleTagManager < Rack::Tracker::Handler class Push < OpenStruct def write "'#{event[:name]}': '#{event[:value]}'" end def event attributes.stringify_values.compact end def attributes to_h.slice(:name, :value) 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
6 entries across 6 versions & 1 rubygems