Class: Rack::Tracker::GoogleAnalytics::EnhancedEcommerce

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rack/tracker/google_analytics/google_analytics.rb

Instance Method Summary collapse

Methods inherited from OpenStruct

#to_h

Instance Method Details

#writeObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rack/tracker/google_analytics/google_analytics.rb', line 30

def write
  hash = self.to_h
  label = hash[:label]
  attributes = hash.except(:label, :type).compact.stringify_values

  [
    "ec:#{self.type}",
    label,
    attributes.empty? ? nil : attributes
  ].compact.to_json.gsub(/\[|\]/, '')
end