Tracking revenue

The JavaScript SDK can track revenue from users by logging Purchase events. Purchase events indicate that a user purchased goods — physical goods or virtual goods — in your application. Logging Purchase events enables reporting on metrics such as total revenue, average revenue per user (ARPU) and average revenue per paying user (ARPPU).

Purchase events

The following example logs a Purchase event for a user purchasing a pair of shoes with item ID “item1″ for 100 US Dollars:

Medio.Events.logEvent({
   event_name: "Purchase",
   action_type: "Purchase",
   unit_price: "100.00", 
   currency: "USD",
   quantity: "1",
   item_id: "6813249X",
   item_category_tag: "Shoes"
});

Required Attributes:

  • event_name, action_type, item_id, unit_price, currency, quantity

Note that item_id should match the catalog being used by Content Recommendation API. currency should be a three-character string (ISO 4217 format).

Purchase events with multiple items

If the shopping cart and checkout process allows users to purchase multiple items at once, it is possible to use action_id 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″ (for $100 and $200), this code will log both purchases in the same transaction (“cart123456″):

Medio.Events.logEvent({
   event_name: "Purchase",
   action_type: "Purchase",
   unit_price: "100.00", 
   currency: "USD",
   quantity: "1",
   item_id: "item1",
   item_category_tag: "Shoes", 
   action_id: "cart123456"
});
Medio.Events.logEvent({
   event_name: "Purchase",
   action_type: "Purchase",
   unit_price: "200.00", 
   currency: "USD",
   quantity: "1",
   item_id: "item2",
   item_category_tag: "Pants",
   action_id: "cart123456"
});