2
votes

I am implementing addItem and addTransaction on a web shop's cart page. Once an order has been placed, I go through the carts content and add each individual item as an addItem with google analytics ecommerce plugin, then I create the transaction and send it altogether to google.

What happens in google analytics is that all transactions show up as having 0 revenue, 0 tax and 0 shipping - but if I enter one individual transaction I can see the item price, name and quantity ordered.

This is the final executing google analytics code once rendered:

ga('require', 'ecommerce');
ga('ecommerce:addItem', {  'id': '143506092300',  'name': 'PRODUCT NAME #1 , COLOR Black',  'price': '229.00',  'quantity': '1'});
ga('ecommerce:addTransaction', {  'id': 'xxx123',  'affiliation': 'Web Shop Name',  'revenue': '229.00',  'shipping': '0.00',  'tax': '45.80'});
ga('ecommerce:send');

Does anyone see what I'm missing here?

1
One thing missing is the transaction id in addTransaction (or is that just a typo in your example ?). - Eike Pierstorff
Sorry that was a typo while I was anonymising the details :-) Thanks! - Alex

1 Answers

0
votes

So I had two issues:

the ID in the addItem block was actually the product ID, but it is supposed to be the transaction ID.

The solution was to have the same ID in all addItem calls and this ID in the transaction call. Additionally, the transaction code should appear before the addItem calls, the following works for me:

ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {  'id': '143506092300',  'affiliation': 'Web Shop Name',  'revenue': '229.00',  'shipping': '0.00',  'tax': '45.80'});
ga('ecommerce:addItem', {  'id': '143506092300',  'name': 'PRODUCT NAME #1 , COLOR Black',  'price': '229.00',  'quantity': '1'});
ga('ecommerce:send');