0
votes

When using the multiple tracker support in analytics.js Ecommerce tracking... https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#multitracker

Does ecommerce.js have to be required for each tracker? Like this... ?

ga('require', 'ecommerce', 'ecommerce.js');  // default tracker object
ga('myTracker.require', 'ecommerce', 'ecommerce.js');  // tracker for another web property
2

2 Answers

0
votes

Yes, be sure to follow the trackerName.pluginName:method method for the transaction objects.

0
votes

Here's a bit more information on this from the Google documentation

You can also use the ecommerce plugin if you have implemented multiple (named) trackers on your page. The plugin works exactly the same as the default tracker, except that the format is: trackerName.pluginName:method. For example if you created a tracker named myTracker:

ga('create', 'UA-XXXX-Y', 'auto', {'name': 'myTracker'}); You would then load the ecommerce plugin for that named tracker using:

ga('myTracker.require', 'ecommerce', 'ecommerce.js'); The to send a transaction, you can create a transaction object and pass it to the named tracker as follows:

var transaction = { 'id': '1234', // Transaction ID. 'affiliation': 'Acme Clothing', // Affiliation or store name.
'revenue': '11.99', // Grand Total. 'shipping': '5' ,
// Shipping. 'tax': '1.29' // Tax. };

ga('myTracker.ecommerce:addTransaction', transaction); Using this syntax, the transaction object can be used on multiple trackers.

Finally you would send the transaction data as follows:

ga('myTracker.ecommerce:send');

Here's the link to the documentation https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#multitracker