美好的一天,
我有一种方法,用于记录Google Analytics事件:
public void sendGoogleAnalyticsCheckoutEvent(Class className, Order order) {
ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
.setTransactionId(order.getId())
.setTransactionRevenue(order.getGrandTotal())
.setTransactionTax(order.getTaxTotal())
.setTransactionShipping(order.getShippingTotal());
HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
.setProductAction(productAction);
List<Variant> variants = order.getItems();
for (Variant variant : variants) {
Product product = new Product();
product.setId(variant.getSku());
product.setName(variant.getName());
product.setVariant("" + variant.getVariantId());
product.setPrice(variant.getPrice());
product.setQuantity((int) variant.getQuantity());
builder.addProduct(product);
}
tracker.setScreenName(className.getSimpleName());
tracker.send(builder.build());
}
FirebaseAnalytics
是否有任何替代方法可用于记录ProductAction
和builder.addProduct()
?