Google Analytics不会显示购买情况,也不显示活动

时间:2014-08-30 20:55:32

标签: android google-analytics e-commerce tracking product

我的Google Analytics for Android存在问题。我正在尝试使用电子商务跟踪,但它不起作用。 我发送了一个热门,Eclipse在LogCat中显示了我

Sending hit to service  ...

Google Analytics(分析)向我显示“实时”事件(类别,操作,标签),但在“转化”下不是购买的产品。

Product product = new Product()
.setName("myproduct");

tracker
.send(new HitBuilders.EventBuilder()
.setCategory(category)
.setAction(action)
.setLabel(label)
.addProduct(product)
.setProductAction(new ProductAction(ProductAction.ACTION_PURCHASE))
.build());

是的,我已在数据视图设置下激活了电子商务

我做错了什么?

1 个答案:

答案 0 :(得分:1)

以下代码适用于我。

另请注意,转化包括目标和电子商务。实时部分仅显示目标。对于电子商务,您必须等待一段时间,直到主要转化中出现该事件 - >电子商务部分(约15分钟或更长时间)。

// Logs a purchase event to Google analytics, for ecommerce tracking.
private void logGooglePurchaseEvent(String transactionId, String productId)
{
    // Look up the product's price.
    double price = getProductPrice(productId);
    // Look up the product's currency.
    String currency = getProductPriceCurrency(productId);

    // Set up the product.
    Product product = new Product()
        .setId(productId)
        .setName(productId)
        .setCategory("iap")
        .setPrice(price)
        .setQuantity(1);

    // Set up the purchase action.
    ProductAction productAction = 
        new ProductAction(ProductAction.ACTION_PURCHASE)
            .setTransactionId(transactionId)
            .setTransactionAffiliation("Google Play")
            .setTransactionRevenue(price);

    // Create the builder, which combines the purchase with the product.
    HitBuilders.EventBuilder builder = 
        new HitBuilders.EventBuilder();
    builder.setProductAction(productAction).addProduct(product);
    builder.setCategory("transaction").setAction("purchase");

    // Create the analytics tracker.
    GoogleAnalytics analytics = GoogleAnalytics.getInstance(_context);
    Tracker tracker = analytics.newTracker(
        getGoogleAnalyticsPropertyId());

    // Send the event, specifying the currency.
    tracker.set("&cu", currency);
    tracker.send(builder.build());
}