Missing data on Android enhanced e-commerce analytics page
Asked Answered
B

1

10

I'm measuring my Android app checkout performance by using the google-analytics SDK. I created a Wrapper that I use in order to send hits (and it works) and exceptions (it works as well). I just can't make it work with eCommerce data.

In order to send ecommerce data i create a product and a productAction

    Product product = new Product()
            .setId(ID)
            .setCategory(category)
            .setBrand(brandID)
            .setCustomDimension(1, typology)
            .setCustomDimension(2, currency)
            .setPrice(getTotal())
            .setQuantity(1);
    // Add the step number and additional info about the checkout to the action.
    ProductAction productAction = new ProductAction(ProductAction.ACTION_PURCHASE)
            .setCheckoutStep(4)
            .setCheckoutOptions("Perform payment");

and then

sendEcommerceCheckoutStep(product, productAction, "performPayment", getApplicationContext())

the body of said method is

    public void sendEcommerceCheckoutStep(Product product, ProductAction productAction, String checkoutStepName, Context context) {
        HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder()
                .addProduct(product)
                .setProductAction(productAction)
                .addImpression(product, checkoutStepName);

        mTracker.setScreenName(checkoutStepName);
        mTracker.send(builder.build());
        mTracker.setScreenName(null);
    }

Now, I'd expect data to flow through analytics (and it does, I checked the adb logs) but I can't see it in analytics web interface.

This is what I see on analytics web interface:

Google Analytics view of e-commerce

As you can see the only column which got data is the "Cart-to-Detail Rate" one. But how can I have a cart-to-detail rate if I don't have any data in any other column?

This was the "product performance" screen. This is the "Product list performance":

produce list performance

all other columns are 0 as well. Why did it list the "add to cart" actions but not the others?

Blister answered 2/8, 2016 at 15:45 Comment(5)
use event instead of setting screen name for each productTilbury
It seems to me that - in order to use Products and ProductActions for Ecommerce - I should use ScreenViewBuilder: developers.google.com/analytics/devguides/collection/android/v4/…Blister
Ok, I see what you mean. I tried with HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder() .addProduct(product) .setProductAction(productAction) .addImpression(product, checkoutStepName); but still I don't get anything in the ecommerce tab of analytics.Blister
@MarcoZanetti Could you find a solution to this? I'm having the same problem. I'd appreciate any help. ThanksPeso
I'm working in another company now so didn't look at that anymore but no, I could not find a solution back then -.-Blister
C
1

The following code is working on my app. I have followed the official transaction guide.

I found a few differences with yours. E.g. the name of the screen name, I don't set it to null later, I don't set the checkout step, I don't set custom dimensions nor impressions.

Feel free to try it:

public void trackPurchase(@NonNull TrackingPurchase trackingPurchase) { 
    HitBuilders.ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder();

    for (TrackingProduct trackingProduct : trackingPurchase.getTrackingProducts()) {
        builder.addProduct(this.createProduct(trackingProduct));
    }
    builder.setProductAction(this.createProductAction(trackingPurchase));

    googleAnalyticsTracker.setScreenName("transaction");
    googleAnalyticsTracker.set("&cu", "USD");
    googleAnalyticsTracker.send(builder.build());
}

@NonNull
private Product createProduct(@NonNull TrackingProduct trackingProduct) {
    return new Product()
            .setId(trackingProduct.getSku())
            .setName(trackingProduct.getName())
            .setCategory(trackingProduct.getCategory())
            .setPrice(trackingProduct.getPrice())
            .setQuantity(trackingProduct.getQuantity());
}

@NonNull
private ProductAction createProductAction(@NonNull TrackingPurchase trackingPurchase) {
    return new ProductAction(ProductAction.ACTION_PURCHASE)
            .setTransactionId(trackingPurchase.getSaleId())
            .setTransactionAffiliation("Android App")
            .setTransactionRevenue(trackingPurchase.getRevenue())
            .setTransactionTax(0)
            .setTransactionShipping(trackingPurchase.getShippingCost())
            .setTransactionCouponCode(trackingPurchase.getCouponCode());
}

TrackingPurchase is a class that just contains the various TrackingProduct which are data to be tracked.

I can see this tracked by checking here:

Google Analytics Ecommerce

For example, you will see revenue and top sellers.

Candlepower answered 15/8, 2016 at 19:50 Comment(1)
Thank you Fernando. I tried with your code and simplified mine but - still - no data flows through ecommerce. :-/Blister

© 2022 - 2024 — McMap. All rights reserved.