Class: GAEvents::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/gaevents/event.rb

Overview

Class to define analytical events expected attributes: tid, cid and t

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Event

As per Measurement Protocol, parameters: v, tid, cid and t should always be present. This gem automatically injects v. Ensure you always pass tid, cid and t while initializing events.



17
18
19
20
# File 'lib/gaevents/event.rb', line 17

def initialize(hash = {})
	 @params = hash.select { |_k, v| v }
	 @params['v'] = 1
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



7
8
9
# File 'lib/gaevents/event.rb', line 7

def params
  @params
end

Instance Method Details

#payloadObject



22
23
24
# File 'lib/gaevents/event.rb', line 22

def payload
	 URI.encode_www_form(@params)
end