【问题标题】:Android: Inapp purchase - Google AnalyticsAndroid:应用内购买 - 谷歌分析
【发布时间】:2012-08-30 14:09:14
【问题描述】:

我在安卓应用中成功实现了应用内购买。我只想在谷歌分析中记录购买事件。如果应用程序在前台,我可以通过 PurchaseObserver 记录事件。但是如果应用程序在后台,如何在谷歌分析中记录事件。目前我正在使用 EasyTracking 库来记录事件。

请帮忙。 提前致谢。

【问题讨论】:

标签: android logging service google-analytics in-app-purchase


【解决方案1】:

使用新的 v2 Google Analytics Android API 尝试类似的操作

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.trackTransaction(myTrans); // Track the transaction.
}

【讨论】:

    猜你喜欢
    • 2013-06-13
    • 2013-05-09
    • 2011-12-14
    • 2014-05-31
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多