Chen Li Yong
Chen Li Yong

Reputation: 6087

Google Analytics Multi Tracking Order is not working completely

I have Google Analytics code like this. This is example of the result on the View Page Source on client's browser, not the JSP code. First create the object and send the page view.

ga('create', 'UA-11111111-1', 'auto');
ga('send', 'pageview');
ga('create', 'UA-11111111-2', 'auto', {'name': 'Rollup'});
ga('Rollup.send', 'pageview');
ga('create', 'UA-11111111-3', 'auto', {'name': 'AnotherRollup'});
ga('AnotherRollup.send', 'pageview');

This is working fine. I mean, I can see all the real time page views on the google analytics for all the three accounts. And then follows the adding transaction code.

ga('require', 'ecommerce');

// create transaction object
var Transaction = {
  'id': '12345', // transaction ID
  'affiliation': 'North East Store',
  'revenue': 100.00',
  'shipping': '0.00',
  'tax': '0.00'
};

// add transaction to all the trackers
ga('ecommerce:addTransaction', Transaction);
ga('Rollup.ecommerce:addTransaction', Transaction);
ga('AnotherRollup.ecommerce:addTransaction', Transaction);

And then follows the code to add items to the transaction.

var Item = {}; // this is to prepare the var for multi items.

Item = {
    'id': '12345',         // transaction ID
    'name': 'Microwave',   // name
    'sku': '111',          // SKU/code.
    'category': 'Kitchen', // Category or variation.
    'price': '20.00',      // Unit price.
    'quantity': '5'        // Quantity.
};

ga('ecommerce:addItem', Item);
ga('RollUp.ecommerce:addItem', Item);
ga('AnotherRollUp.ecommerce:addItem', Item);

And then follows the code to send all these orders to google analytics.

//submits transaction to the Analytics servers
ga('ecommerce:send');
ga('Rollup.ecommerce:send'); 
ga('AnotherRollup.ecommerce:send');

The problem is, the order is only received/updated on the google analytics for the first account (which is the unnamed/default in this javascript code case). I thought it was because I use the wrong google analytics tracker account codes for the other two. But I have recheck and the other two tracker account codes are correct, and I can see the page views in real time. So that mustn't be because of that. My source for this is from:

https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#multitracker

I've checked everything and everything is correct according to that manual. But still I can't get results for the other two trackers (Rollup and AnotherRollup). Is there anything wrong with my code? Or the problem is somewhere else? Thank you very much.

Upvotes: 1

Views: 169

Answers (1)

nyuen
nyuen

Reputation: 8907

You would need to include the tracker name each time you include the ecommerce library:

ga('require', 'ecommerce');
ga('RollUp.require', 'ecommerce');
ga('AnotherRollUp.require', 'ecommerce');

This is even documented here: https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#multitracker

Upvotes: 1

Related Questions