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



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rack/tracker/google_analytics/google_analytics.rb', line 25

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