File: event.rb

package info (click to toggle)
ruby-rack-google-analytics 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 164 kB
  • ctags: 48
  • sloc: ruby: 287; makefile: 8
file content (15 lines) | stat: -rw-r--r-- 521 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require "active_support/json"
require "active_support/ordered_hash"

module GoogleAnalytics

  # A Struct that mirrors the structure of a custom var defined in Google Analytics
  # see https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
  class Event < Struct.new(:category, :action, :label, :value)

    def write
      { hitType: 'event', eventCategory: self.category, eventAction: self.action, eventLabel: self.label, eventValue: self.value }.select{|k,v| v }.to_json
    end

  end
end