Tracking revenue

The SDK allows you to easily track revenue from users by logging revenue events. If you have an application that allows users to purchase items or otherwise earn revenue from users, logging revenue events allows you to see reports on metrics such as total revenue, average revenue per user (ARPU), and average revenue per paying user (ARPPU).

We classify revenue events as purchase events or earn events. Purchase events indicate that a user purchased goods — physical goods or virtual goods — in your application. Earn events indicate that you earned revenue as a result of a user’s action. Earn events often represent revenue from ads, particularly in-house ads or promotions.

Purchase events

Use the Medio.MedioEventExtras.logPurchaseEvent method to log a purchase event. For example, if a user purchases a a pair of shoes with item ID “item1″ for 100 US Dollars, you can log that purchase by writing the following line of code:

Medio.EventApi.extras().logPurchaseEvent("item1",
    100.00, Medio.MedioEventExtras.Currency_USD,
    false, 1, null, null);

You can include a number of optional parameters with purchase events such as an item’s category and type in a Medio.LogPurchaseOptions object. To indicate that the purchased item is merchandise in the “Shoes” category, you can write the following code:

var options = Medio.MedioEventExtras.createLogPurchaseOptions();
options.setItemCategoryTag("Shoes");
options.setItemType(Medio.MedioEventExtras.PurchaseItemType_Merchandise);

Medio.EventApI.extras().logPurchaseEvent("item1",
    100.00, Medio.MedioEventExtras.Currency_USD,
    false, 1, options, null);

See the API Reference for more information on the optional parameters that you can include with purchase events.

Purchase events with multiple items

If your application includes a shopping cart and checkout process that allows users to purchase multiple items at once, you can use the SDK’s Medio.MedioEventExtras.openPurchaseCart and Medio.MedioEventExtras.closePurchaseCart methods to indicate that a user purchased items in the same transaction. For example, if a user checks out and purchases two items with item IDs “item1″ and “item2″ — both for 100 US Dollars — you would write the following code to log both purchases in the same transaction:

Medio.EventApi.extras().openPurchaseCart();
Medio.EventApi.extras().logPurchaseEvent("item1",
    100.00, Medio.MedioEventExtras.Currency_USD,
    false, 1, null, null);
Medio.EventApi.extras().logPurchaseEvent("item2",
    100.00, Medio.MedioEventExtras.Currency_USD,
    false, 1, null, null);
Medio.EventApi.extras().closePurchaseCart();

Earn events

Use the Medio.MedioEventExtras.logEarnEvent method to log an event indicating that you earned revenue from a user. For example, if a user accepts an in-house promotion and you earn 0.99 US Dollars for each promotion, you can log that revenue by writing the following line of code:

Medio.EventApi.extras().logEarnEvent(0.99,
    Medio.MedioEventExtras.Currency_USD,
    null, null);