We have provided a list of Events with their example usage that can be integrated for Content based Applications. Please find them below:
1. Purchase Event
This is used to track the successful Purchase events or paid subscription to the Application.
You will need to call the below method of MTractionEventTracker Class to track the In-App Purchase event in your Application.
Public static void trackPurchase(Context context, Purchase purchase);
// Product List Array Definition List productList = new ArrayList(); // Product Constructor Call Product product1 = new Product(productIdentifier, productName, price, quantity);
- Mandatory parameters (Product):
- Product Identifier - Unique Product Identifier
- Product Name - Name of the Product
- Price - Price of the Product
- Quantity - Quantity of the Product being Purchased
- Optional parameters (Product):
- Brand - Brand Name of the Product
- Product Discount - Discount applied for the Product
- Category - Product Category
// Adding the product to the Product List productList.add(product1); // Purchase Constructor Call Purchase purchase = new Purchase(userId, revenue, Purchase.PaymentMode.DEBIT_CARD, locale, transactionId, Purchase.Frequency.XXX, productList);
- Mandatory parameters (Purchase):
- User Id - Unique User Identifier
- Revenue - Total Revenue generated from this Purchase event
- Purchase.PaymentMode.XXX - XXX can take any of the predefined values for payment methods, [CREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET]
-
Locale - Currency code used for this purchase. We can get currency code information precisely in either of the following ways:
-
Default from device configuration:
Locale locale = Locale.getDefault();
Note: Recommended for more accuracy. -
Custom setting:
Locale locale = new Locale("JA"/*Language Code*/, "JP" /*Country Code*/);
Note: Click here to view the list of Country codes (ISO-3166) & Language codes (ISO-639).
-
Default from device configuration:
- Transaction Id - Unique Purchase Transaction Identifier
- Purchase.Frequency.XXX - XXX can take any of the predefined values for payment frequency, [ONCE or RECURRING] representing One Time Payment or Subscription based Payment respectively
- Product List - Array of the list of products purchased
- Optional parameters (Purchase):
- Loyalty - Loyalty points applied on the Purchase
- Overall Discount - Discount applied for the Purchase
- Service Charge - Service Charge applied for the Purchase
- Location - Geolocation of the Event
Sample Code
// Example Longitude & Latitude code (Long / Lat is optional) LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); // Product List Array Definition List productList = new ArrayList(); // Example Product Constructor Call with the mandatory parameters Product product1 = new Product(“12345”, “Cook Books”, 14.99, 1); // Examples for other parameters passed for the Product Class (These are optional) product1.setBrand(“Gordon Ramsay”) .setCategory("Books") .setProductDiscount(5.00); // Adding the product to the Product List productList.add(product1); // Example Purchase Constructor Call with the mandatory parameters Purchase purchase= new Purchase(“123”, 24.65, Purchase.PaymentMode.DEBIT_CARD Locale.getDefault(), “1000123” , Purchase.Frequency.RECURRING, productList); // Examples for other parameters passed for the Purchase Class (These are optional) purchase.setLoyalty(350.00) .setOverallDiscount(5.00) .setServiceCharge(4.99) .setLocation(location.getLatitude(), location.getLongitude()); // trackPurchase method call MTractionEventTracker.trackPurchase(this.getApplicationContext(), purchase);
2. Content Viewed Event
This is used to track the event triggered when the user has viewed any content on the Application.
You will need to call the below method of MTractionEventTracker Class to track the Content viewed event in your Application.
Public static void trackContentViewed(Context context, ContentViewed contentViewed);
ContentViewed trackContentViewed = new ContentViewed(userId, revenue, identifier, ContentViewed.MediaType.VIDEO, locale);
- Mandatory parameters (Content Viewed):
- User Id - Unique User Identifier
- Revenue - Total Revenue generated from this Content Viewed event
- Identifier - Unique Content Identifier
- ContentViewed.MediaType.XXX - XXX can take any of the predefined values for type of content viewed, [AUDIO or VIDEO or TEXT or IMAGE]
-
Locale - Currency code used for this purchase. We can get currency code information precisely in either of the following ways:
-
Default from device configuration:
Locale locale = Locale.getDefault();
Note: Recommended for more accuracy. -
Custom setting:
Locale locale = new Locale("JA"/*Language Code*/, "JP" /*Country Code*/);
Note: Click here to view the list of Country codes (ISO-3166) & Language codes (ISO-639).
-
Default from device configuration:
- Optional parameters (Content Viewed):
- Product Name - Title of the Content
- Category - Content Category
- Page Name - Page that triggered the Event
- Location - Geolocation of the Event
Sample Code
// Example Longitude & Latitude code (Long / Lat is optional) LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); // Example Constructor Call with the mandatory parameters ContentViewed trackContentViewed = new ContentViewed(“123”, 123.00, “12345”, ContentViewed.MediaType.VIDEO, Locale.getDefault()); // Examples for other parameters passed with the event (These are optional) trackContentViewed.setProductName(“Article on Electronic gadgets”) .setCategory(“Technology”) .setPageName(“Article”) .setLocation(location.getLatitude(), location.getLongitude()); // trackContentViewed method call MTractionEventTracker.trackContentViewed(this.getApplicationContext(), trackContentViewed);