Sha256: f0bf6740d5f3016efa59f9e7c3ddfe6ab7057e03ca88c5077fb9888e9e4702ed

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

class GAEvents
	class Event
		attr_accessor :params

		# Initialize Events by passing a hash.
		# Keys could be any GA allowed parameter.
		# Please refer Measurement Protocol Parameter Reference for available options:
		# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters

		# As per Measurement Protocol, parameters: v, tid, cid and t should always be present.
		# This gem automatically injects v and tid. Ensure you always pass cid and t when
		# initializing events.
		def initialize(hash = {})
			@params = hash.reject { |k,v| !v }
			@params["v"] = 1
		end

		def payload(tid)
			URI.encode_www_form(@params.merge({"tid": tid}))
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gaevents-1.0 lib/gaevents/event.rb