Search code examples
androidamazon-web-servicesanalyticsmobile-analyticsamazon-mobile-analytics

Populate AWS Mobile Analytics Revenue graph


I'm working on a proof of concept android application that uses AWS Mobile Analytics to track sessions and events in the app. I'm able to pause and resume sessions, and create custom events, and everything reflects in the corresponding graphs as expected. Now in the Mobile Analytics Console, there are graphs that show Revenue or some metric that has something to do with the Revenue (ARPDAU, ARPPDAU), as well as a Revenue tab, all of which currently does not have any value. Currently my Lifetime Value Per User looks like this:

revenue

How does the Revenue tab get populated? Do I have to actually purchase something with my app using Google In-app purchase, FB payments, or Amazon payment to have it populated? Will it get populated automatically when a user makes a purchase? Or is there an API call somewhere that I can call to populate these values?

The question sounds silly, but I honestly could not find a decent documentation regarding this, and testing out the payments would take me a while as I have limited control over the accounts I'm using for this PoC.


Solution

  • Assuming you are using the AWS Android (Java) SDK, it looks like they have a builder pattern for sending monetization events.

    http://docs.aws.amazon.com/AWSAndroidSDK/latest/javadoc/

    They have a separate pattern for each type of store, so code for google play would look like: (Shamelessly copied from the docs)

    // get the event client from your MobileAnalyticsManager instance
    EventClient eventClient = mobileAnalyticsManager.getEventClient();
    
    // create a builder that can record purchase events for Google Play IAP
    GooglePlayMonetizationEventBuilder builder = GooglePlayMonetizationEventBuilder.create(eventClient);
    
    // build the monetization event with the product id, formatted item price, transaction id, and quantity
    // product id and formatted item price can be obtained from the JSONObject returned by a product sku request to Google's In App Billing API
    // transaction id is obtained from the Purchase object that is returned upon the completion of a purchase
    // Google IAP currently only supports a quantity of 1
    Event purchaseEvent = builder.withProductId(sku).withFormattedItemPrice(price).withTransactionId(purchase.getOrderId()).withQuantity(1).build();
    
    // record the monetization event
    eventClient.recordEvent(purchaseEvent);
    

    Page where sample code is taken

    For Amazon in-app purchase

    For FB purchase, I'd assume