很长一段时间以来,我一直在尝试在 android 中实现谷歌分析,但我一直在实现最终的交易代码。我做了什么
MyApp 应用程序 = (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());
}
理想情况下,要发送的交易收入在交易的所有命中中必须相同。但是当我这样做时,仪表板只会向我显示作为交易的一部分发送的第一个项目。