Class: GoogleAnalytics::Events::Ecommerce::AddItem

Inherits:
GoogleAnalytics::Event show all
Defined in:
lib/google-analytics/events/events.rb

Overview

JavaScript equivalent:

_gaq.push(['_addItem',
  '1234',           // order ID - required
  'DD44',           // SKU/code - required
  'T-Shirt',        // product name
  'Green Medium',   // category or variation
  '11.99',          // unit price - required
  '1'               // quantity - required
]);

Instance Attribute Summary

Attributes inherited from GoogleAnalytics::Event

#action, #name, #params

Instance Method Summary collapse

Methods inherited from GoogleAnalytics::Event

#single_event?

Constructor Details

#initialize(order_id, product_id, product_name, product_variation, unit_price, quantity) ⇒ AddItem

Returns a new instance of AddItem.



204
205
206
207
208
209
210
211
212
213
# File 'lib/google-analytics/events/events.rb', line 204

def initialize(order_id, product_id, product_name, product_variation, unit_price, quantity)
  super('ecommerce:addItem', {
    :id => order_id.to_s,
    :sku => product_id.to_s,
    :name => product_name.to_s,
    :category => product_variation.to_s,
    :price => unit_price.to_s,
    :quantity => quantity.to_s
  })
end