I am trying to implement google analytics in android from a long time and I am stuck in implementing the final transaction code. What I have done
MyApp application = (MyApp) getApplication();
Tracker mTracker = application.getDefaultTracker();
Product product;
ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE);
mOrderedItems = mOrderPlaceResponse.getOrderDetails().getItemDetails();
productAction.setTransactionId(mOrderPlaceResponse.getNumber());
for (ItemDetail lineItem : mOrderedItems) {
product = new Product()
.setId(String.valueOf(lineItem.getDesignId()))
.setName(lineItem.getTitle()).setQuantity(lineItem.getQuantity());
product.setPrice(lineItem.getSoldAtPrice())
.setCategory(lineItem.getType());
productAction.setProductActionList(lineItem.getSource());
productAction.setTransactionRevenue(lineItem.getSoldAtPrice() * lineItem.getQuantity());
HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder()
.addProduct(product)
.setProductAction(productAction);
mTracker.send(builder.build());
}
Ideally the transaction revenue to be sent must be same in all hits for a transaction. But when I do that the dashboard just shows me the first item sent as part of transaction.