我正在为我的 android 应用程序实施 Google Analytics Ecomerce 跟踪。
根据 GA 的文档(请参阅下面的代码),我需要创建一个新的Transaction.Builder并需要一个“Transaction Id”。我发现 Google 没有返回交易 ID,而是返回了订单 ID。- 问题是如何检索交易 ID 或者我可以使用订单 ID 代替吗?返回订单 ID 的示例格式为:12999763169054705758.1356245045384470
/**
* The purchase was processed. We will send the transaction and its associated line items to Google Analytics,
* but only if the purchase has been confirmed.
*/
public void onPurchaseCompleted() {
Transaction myTrans = new Transaction.Builder(
"0_123456", // (String) Transaction Id, should be unique.
(long) (2.16 * 1000000)) // (long) Order total (in micros)
.setAffiliation("In-App Store") // (String) Affiliation
.setTotalTaxInMicros((long) (0.17 * 1000000)) // (long) Total tax (in micros)
.setShippingCostInMicros(0) // (long) Total shipping cost (in micros)
.build();
myTrans.addItem(new Item.Builder(
"L_789", // (String) Product SKU
"Level Pack: Space", // (String) Product name
(long) (1.99 * 1000000), // (long) Product price (in micros)
(long) 1) // (long) Product quantity
.setProductCategory("Game expansions") // (String) Product category
.build());
Tracker myTracker = EasyTracker.getTracker(); // Get reference to tracker.
myTracker.sendTransaction(myTrans); // Send the transaction.
}