Art Olshansky
Art Olshansky

Reputation: 3356

How I can track `ecommerce:addItem` or `ecommerce:addTransaction` by angulartics2?

I use angulartics2 for tracking pageviews.

How I can track ecommerce:addItem or ecommerce:addTransaction by angulartics2 in angular 5 application? Or maybe I can implement it more native?

p.s. I added ga('require', 'ecommerce');

Upvotes: 1

Views: 580

Answers (1)

Art Olshansky
Art Olshansky

Reputation: 3356

For now, angulartics2 haven't an implementation of ecommerce tracking.

You can just use the global ga function.

For example (and you can find native examples in Ecommerce Tracking):

(window as any).ga('ecommerce:addTransaction', {
  'id': '1234',                     // Transaction ID. Required.
  'affiliation': 'Acme Clothing',   // Affiliation or store name.
  'revenue': '11.99',               // Grand Total.
  'shipping': '5',                  // Shipping.
  'tax': '1.29'                     // Tax.
});

and after all needed adds call ecommerce:send by

(window as any).ga('ecommerce:send');

Upvotes: 1

Related Questions