1. Home
  2. Integrations
  3. iOS Native Events Setup Guide
  4. Content Based Applications – iOS

Content Based Applications – iOS

We have provided a list of Events with their example usage that can be integrated for Content based Applications. Please find them below:

Note: Please ensure to include the MTraction header file (as shown below) in the class of your project from where the in App event methods have to be invoked.

#import <mTraction/MTraction.h>

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 to track the In-App Purchase event in your Application.

[[MTraction mTractionManager] trackPurchase:purchase];
// Product List Array Definition
NSMutableArray *productList=[[NSMutableArray alloc] init];

// Product Constructor Call
-(id)initWithProductIdentifier:(NSString*)identifier productName:(NSString*)productName price:(float)price quantity:(short)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 addObject:product1];

// Purchase Constructor Call
-(void)trackPurchase:(Purchase*) purchase;

  • Mandatory parameters (Purchase): 
    • User Id – Unique User Identifier
    • Revenue – Total Revenue generated from this Purchase event
    • Payment ModeCREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET
    • Transaction Id – Unique Purchase Transaction Identifier
    • Purchase FrequencyONCE or RECURRING representing One Time Payment or Subscription based Payment respectively
    • Product List – Array of the list of products purchased
    • Locale – Currency code used for this event.

      NOTE: For passing custom currency code, Follow the sample below: 

      // For Custom Currency Code
      NSLocale *currencyCode = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] ;
      
  • 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)
#import <CoreLocation/CoreLocation.h>
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  NSLog(@"didUpdateToLocation: %@", newLocation);
  CLLocation *currentLocation = newLocation;
  if (currentLocation != nil) 
  {
    double longitude = currentLocation.coordinate.longitude;
    double latitude = currentLocation.coordinate.latitude;
  }
}

// Default Currency Code from the local instance
NSLocale *currencyCode = [NSLocale currentLocale];

// Product List Array Definition
NSMutableArray *productList=[[NSMutableArray alloc] init];

// Example Product Constructor Call with the mandatory parameters
Product *product1 = [[Product alloc]initWithProductIdentifier:@"12345" productName:@"Cook Books" price:14.99 quantity:1];

// Examples for other parameters passed for the Product Class (These are optional)
  [product1 setBrand:@"Gordon Ramsay"];
  [product1 setProductDiscount:5.00];
  [product1 setCategory:@"Books"];

// Adding the product to the Product List
[productList addObject:product1];

// Example Purchase Constructor Call with the mandatory parameters
Purchase *purchase = [[Purchase alloc] initWithPurchaseUserId:@"123" revenue:24.65 currency:currencyCode transactionId:@"1000123" paymentMode:DEBIT_CARD frequencyMode:ONCE ProductList:productList];

// Examples for other parameters passed for the Purchase Class (These are optional)
  [purchase setLoyalty:350.00];
  [purchase setOverallDiscount:5.00];
  [purchase setServiceCharge:4.99];
  [purchase setLocationLatitude:latitude longitude:longitude]

// trackPurchase method call
[[MTraction mTractionManager] trackPurchase: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 to track the Content viewed event in your Application.

[[MTraction mTractionManager]trackContentViewed:contentViewed];
-(void)trackContentViewed:(ContentViewed*) contentViewed;

  • Mandatory parameters (Content Viewed): 
    • User Id – Unique User Identifier
    • Revenue – Total Revenue generated from this Content Viewed event
    • Identifier – Unique Content Identifier
    • Media Type – Type of content viewed, AUDIO or VIDEO or TEXT or IMAGE
    • Locale – Currency code used for this event.

      NOTE: For passing custom currency code, Follow the sample below: 

      // For Custom Currency Code
      NSLocale *currencyCode = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] ;
      
  • 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)
#import <CoreLocation/CoreLocation.h>
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
  NSLog(@"didUpdateToLocation: %@", newLocation);
  CLLocation *currentLocation = newLocation;
  if (currentLocation != nil) 
  {
    double longitude = currentLocation.coordinate.longitude;
    double latitude = currentLocation.coordinate.latitude;
  }
}

// Default Currency Code from the local instance
NSLocale *currencyCode = [NSLocale currentLocale];

// Example Constructor Call with the mandatory parameters
ContentViewed *contentViewed = [[ContentViewed alloc]initWithContentViewedUserID:@"123" Revenue:123.00 Identifier:@"12345" MediaType:VIDEO Currency:currencyCode];

// Examples for other parameters passed with the event (These are optional)
  [contentViewed setProductName:@"Article on Electronic gadgets"];
  [contentViewed setPageName:@"Article"];
  [contentViewed setCategory:@"Technology"];
  [contentViewed setLocationLatitude:latitude longitude:longitude];


// trackContentViewed method call
[[MTraction mTractionManager]trackContentViewed:contentViewed];
Was this article helpful to you? Yes No

How can we help?