1
votes

Im trying to add custom metrics to transactions on google analytics. It must be per transaction. Currently I'm adding transactions like this.

    ga('ecommerce:addTransaction', {
        'id':           '',
        'affiliation':  '',
        'revenue':      '',
        'tax':          '',
        'currency':     ''
    });
    ga('ecommerce:addItem', {
        'id':       '',
        'name':     '',
        'sku':      '',
        'category': '',
        'price':    '',
        'currency': '',
        'quantity': ''
    });

Now what I was thinking was adding the following to the transaction but don't quite know if its the right way to do it.

ga('ecommerce:addProduct', {'metric1': hasTransacted});

I know with page views custom metrics can be added to page view like this

ga('set', 'metric1', '1');

ga('send', 'pageview');

But Im trying to add it to a transaction instead.

Any advice would be greatly appreciated.

1

1 Answers

0
votes

You should be able to add the metric to the transaction hit, just like in your example with addProduct. Here is a similar question asked here is it possible to send custom variables to Google analytics while using ecommerce extension.