如何在Google Analytics电子商务中获取交易ID?

时间:2013-09-25 10:17:58

标签: android google-analytics

我正在为我的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.
}

1 个答案:

答案 0 :(得分:1)

在Android的Google Analytics sdk中,transaction id指的是电子商务应用中每个客户交易的唯一标识符。在任何电子商务应用程序中,每个客户交易都有一个唯一的标识号,可用作主键,同时将交易详细信息存储在您站点的数据库中。因此,在向分析发送电子商务类型时,您可以使用相同的唯一ID,在您的情况下似乎是order id。 另请注意,在将项目详细信息发送到交易时,您应使用相同的交易ID /订单ID,GA将使用此链接交易和项目详细信息。