Class: Caboose::GA
- Inherits:
-
Object
- Object
- Caboose::GA
- Defined in:
- app/models/caboose/ga.rb
Overview
Google Analytics
Class Method Summary collapse
Class Method Details
.event(site_id, category, action, label = nil, value = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/caboose/ga.rb', line 6 def self.event(site_id, category, action, label = nil, value = nil) site = Site.where(:id => site_id).first return if site.nil? sc = site. ga_id = sc.google_analytics_id return if ga_id.nil? || ga_id.strip.length == 0 params = { 'v' => 1, 'tid' => ga_id, 'cid' => site.id, 't' => "event", 'ec' => category, 'ea' => action } params['el'] = label if label params['ev'] = value if value HTTParty.post('http://www.google-analytics.com/collect', :body => params) end |