Log In

The Standard Events API was designed taking into consideration industry standard app events. MOCA Supports the following:

  • User Login - Enables you to identify a user and register user sessions by tracking login and logout events.
  • View History - By adding the item ID and, optionally, the category to the call, this method records this view events in the view collection within the current user profile.
  • Favourites List - You can easily manage user favourites by easily adding, removing or clearing the list. The separate favlist is maintained per each user, including an anonymous user.
  • Wish List - With methods for adding to wishlist, removing from wishlist and clearing the wishlist, you can easily track the main actions associated to wishlists. Currently only one wishlist per user is supported, including an anonymous user.
  • Shopping Cart - Composed of adding, removing, clearing, checkout begin and checkout completed actions you can track the shopping cart lifecycle of a current user.
  • Purchase History - Like the above, but this is focused on tracking purchases when a shopping cart isn’t implemented.
  • Shared items - By adding the item ID and, optionally, the category to the call, this method tracks the share event in the user profile.
  • Content Rating - By adding the item ID and, optionally, the category and the rating to the call, this method records the content rating event in the user profile.

The Standard Events API is part of the Android 2.7.0 MOCA SDK.

Track an item viewed by current user. Requires unique item identifier, optional category string and recommended flag. Mark recommended = true flag only when the item was recommended to the user by the App, for all other scenarios user recommended = false.

MOCA.trackViewed(@NonNull String itemId, String category, bool recommended)
MOCA.trackViewed(@NonNull String itemId, bool recommended)

//Example
MOCA.trackViewed("sku-123", "Shirt", false);

Track an item added/removed to Favourites List of the current user or clear the list.

MOCA.addToFavList(@NonNull String itemId)
MOCA.removeFromFavList(@NonNull String itemId)
MOCA.clearFavList()

//Examples
 
// item sku-123 added to favlist 
MOCA.addToFavList("sku-123");

// item sku-13 removed from favlist
MOCA.removeFromFavList("sku-13");

// favourite list cleared
MOCA.clearFavList();

Track/remove items from user Wishlist or clear it

MOCA.addToWishList(@NonNull String itemId)
MOCA.removeFromWishList(@NonNull String itemId)
MOCA.clearWishList()

//Examples  
  
// item sku-123 added to wish list 
MOCA.addToWishList("sku-123");

// item sku-13 removed from wish list
MOCA.removeFromWishList("sku-13");

// wish list cleared
MOCA.clearWishList();

Create cart item. The item represents a product that can be purchased. Cart is persistent which means it will preserve its content after restarting the App.

MOCAItem item = MOCA.createItem(@NonNull String itemId, String category, 
                                double unitPrice, String currency)

Where:

  • itemId - unique item identifier. Item represents a product with unique ID, belongs to a category, is associated unitary price and currency
  • category - item category (optional)
  • unitPrice - unitary price for the item, expressed in currency
  • currency - price currency, 3-letter ISO code or virtual currency name

Add/update/remove item to/from cart. You may add one or multiple items to the cart. Each item will be represented as cart line object. Cart line object contains the item and the quantity of that item. Given that item has a unique identifier adding the same item multiple times via this call will result in adding the added quantities.

MOCA.addToCart(@NonNull MOCAItem item, int quantity)
MOCA.updateCart(@NonNull String itemId, int newQantity)
MOCA.removeFromCart(@NonNull String itemId)
MOCA.clearCart()

Begin checkout of the cart and Complete Checkout. This indicates the user has started the checkout process with the intention of the making the purchase. Once completed, execute completeCheckout.

MOCA.beginCheckout()
MOCA.completeCheckout()

Example of MOCA Cart usage:

// create item sku-123 object
MOCAItem item123 = MOCA.createItem("sku-123", "Food", 75.0, "EUR");
// 2 unit of item sku-123 added to cart
MOCA.addToCart(item123, 2);
// update quantity to 3 units
MOCA.updateCart("sku-123", 3);
// begin checkout
MOCA.beginCheckout();
...
// purchase completed
MOCA.completeCheckout();

Purchase history can be tracked even if the App doesn't support a Cart object.

MOCA.trackPurchased(@NonNull String itemId, String category, double unitPrice,
                    String currency, int quantity)
MOCA.trackPurchased(@NonNull MOCAItem item, int quantity)

Track item or content shared by current user:

MOCA.trackShared(@NonNull String itemId)

Track user based ratings:

MOCA.trackContentRated(@NonNull String itemId, String category, double rating)
MOCA.trackContentRated(@NonNull String itemId, double rating)

Track user login/logout: Login call restores all user profile related data to previous session. Logout restores an anonymous user profile.

MOCAUser user = MOCA.getInstance().login(@NonNull String userId)

if (MOCA.getUser() != null) { 
   MOCA.getUser().logout();
}