Reputation: 119
I've, to the best of my knowledge, successfully integrated Google Aanlytics tracking in an Android app. When viewing the results web, section Conversions - eCommerce - Transactions, the tracked transactions appear correctly, save for the item quantity, which is always zero. However, when debugging my code, the quantity stored in the transaction object is correct. I've also waited several days (about a week), in case the results would update themselves, to no avail. Is there anything "special" I should do to track the item quantity of a transaction? Could this be a bug in the Android GA SDK?
I'm attaching the code I'm using, just in case:
tracker.addTransaction(new Transaction.Builder(orderPK, totalPrice).setStoreName("").setTotalTax(totalTax).setShippingCost(shipping).build());
Item.Builder builder = new Item.Builder(orderPK, productPK, price, quantity);
builder.setItemCategory(category);
Item item = builder.build();
tracker.addItem(item);
tracker.trackTransactions();
tracker.dispatch();
tracker.clearTransactions();
Upvotes: 2
Views: 860
Reputation: 11
Am giving a working code which has worked for me. please try this code
tracker = GoogleAnalyticsTracker.getInstance();
tracker.addTransaction(new Transaction.Builder("3000",25000).setStoreName("MarIoS").setTotalTax(3.23).setShippingCost(10.44).build());
Item.Builder builder = new Item.Builder("3000", "Mobile",5000,5);
builder.setItemCategory("Electronics");
builder.setItemName("SamsunG");
Log.d("json","In Transaction");
Item item = builder.build();
tracker.addItem(item);
tracker.trackTransactions();
tracker.dispatch();
Upvotes: 1
Reputation: 119
It's been a while, but I found the problem, so I'm leaving it posted here.
It turns out there is a field of the item, the name, which is mandatory, though it's not listed anywhere as such (other than in the JS API, where I found it).
So the solution is to add the following line:
builder.setItemName(name);
Upvotes: 0