railslove / rack-tracker

Tracking made easy: Don’t fool around with adding tracking and analytics partials to your app and concentrate on the things that matter.
https://www.railslove.com/open-source
MIT License
647 stars 121 forks source link

Google Analytics enhanced_ecommerce #118

Closed cfgv closed 6 years ago

cfgv commented 6 years ago

How set action_type option?

For example I need set purchase option:

ga('ec:setAction', 'purchase', {          // Transaction details are provided in an actionFieldObject.
  'id': 'T12345',                         // (Required) Transaction id (string).
  'affiliation': 'Google Store - Online', // Affiliation (string).
  'revenue': '37.39',                     // Revenue (currency).
  'tax': '2.85',                          // Tax (currency).
  'shipping': '5.34',                     // Shipping (currency).
  'coupon': 'SUMMER2013'                  // Transaction coupon (string).
});
bumi commented 6 years ago

Hi @cfgv, for google analytics this should help you: https://github.com/railslove/rack-tracker#ecommerce or look at the code: https://github.com/railslove/rack-tracker/blob/master/lib/rack/tracker/google_analytics/template/google_analytics.erb

but this issue tracker is not a support forum.

JCEsmeraldo commented 5 years ago

How set action_type option?

For example I need set purchase option:

ga('ec:setAction', 'purchase', {          // Transaction details are provided in an actionFieldObject.
  'id': 'T12345',                         // (Required) Transaction id (string).
  'affiliation': 'Google Store - Online', // Affiliation (string).
  'revenue': '37.39',                     // Revenue (currency).
  'tax': '2.85',                          // Tax (currency).
  'shipping': '5.34',                     // Shipping (currency).
  'coupon': 'SUMMER2013'                  // Transaction coupon (string).
});

Were you able to find a way?

cfgv commented 5 years ago

@JCEsmeraldo I did it this way

t.google_analytics :enhanced_ecommerce, {
  type: 'setAction',
  label: 'purchase',
  id: @reservation.id,
  revenue: @reservation.total,
  coupon: @reservation.coupon
}