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

mCommerce Applications – iOS

We have provided an Event with example that can be integrated for Applications that belong to the Healthcare Vertical. 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 Purchase transaction of the users after they have successfully completed their payment of their Purchase within your 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 &amp;amp; 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:@"123" productName:@"Targus Backpack" price:29.99 quantity:1];

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

// 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:29.99 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:65.00];
  [purchase setOverallDiscount:5.00];
  [purchase setServiceCharge:4.99];
  [purchase setLocationLatitude:latitude longitude:longitude];

// trackPurchase method call
[[MTraction mTractionManager] trackPurchase:purchase];

2. Add To Cart Event

This is used to track each product added by the user to the list of items, he may be willing to purchase on the Application.

You will need to call the below method to track the Add to Cart event in your Application.

[[MTraction mTractionManager]trackAddToCart:addToCart];
-(void)trackAddToCart:(AddToCart*) addToCart;

  • Mandatory parameters (Add to Cart):         
    • User Id – Unique User Identifier
    • Identifier – Unique Event Identifier
    • Product Name – Name of the Product
    • Category – Product Category
    • Price – Price of the Product
    • 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 (Add to Cart):        
    • Quantity – Quantity of products added to cart
    • Brand – Brand of the product added to cart
    • Product Discount – Discount applicable for the product added to cart
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude &amp;amp; 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
AddToCart *addToCart = [[AddToCart alloc]initWithAddToCartUserID:@"123" Identifier:1234567 ProductName:@"Targus Backpack" Category:@"Bags" Price:29.99 Currency:currencyCode]

// Examples for other parameters passed with the event (These are optional)
  [addToCart setQuantity:1];
  [addToCart setBrand:@”Targus”];
  [addToCart setProductDiscount:5.00];
  [addToCart setPageName:@"Product Details"];
  [addToCart setLocationLatitude:latitude longitude:longitude];

// trackAddToCart method call
[[MTraction mTractionManager]trackAddToCart:addToCart];

3. Add To Wishlist Event

This is used to track each product added by the user to the list of his desired items, he may be willing to purchase at a later time on the Application.

You will need to call the below method to track the Add to Wishlist event in your Application.

[[MTraction mTractionManager]trackAddToWishList:addToWishList];
-(void)trackAddToWishList:(AddToWishList*) addToWishList;

  • Mandatory parameters (Add to Wishlist):         
    • User Id – Unique User Identifier
    • Identifier – Unique Event Identifier
    • Product Name – Name of the Product
    • Category – Product Category
    • Price – Price of the Product
    • 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 (Add to Wishlist):        
    • Brand – Brand of the product added to cart
    • Product Discount – Discount applicable for the product added to cart
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude &amp;amp; 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
AddToWishList *addToWishList = [[AddToWishList alloc] initWithAddToWishListUserID:@"123" Identifier:@"1234567" ProductName:@"Targus Backpack" Category:@"Bags" Price:29.99 Currency:currencyCode];

// Examples for other parameters passed with the event (These are optional)
  [addToWishList setBrand:@"Targus"];
  [addToWishList setProductDiscount:5.00];
  [addToWishList setPageName:@"Product Details"];
  [addToWishList setLocationLatitude:latitude longitude:longitude];

// trackAddToWishlist method call
[[MTraction mTractionManager]trackAddToWishList:addToWishList];

4. Checkout Initiated Event

This is used to track the purchase initiation event before the users make their payment towards purchase in the Application.

You will need to call the below method to track the Checkout Initiated event in your Application.

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

// CheckoutItem Constructor Call
-(id)initWithCheckoutItemIdentifier:(NSString*)identifier productName:(NSString*)productName price:(float)price quantity:(short)quantity category:(NSString*)category;

  • Mandatory parameters (Checkout Item):         
    • Identifier – Unique Product Identifier
    • Product Name – Name of the Product
    • Price – Price of the Product
    • Quantity – Quantity of the Product being Purchased
    • Category – Product Category
  • Optional parameters (Checkout Item):        
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
// Adding the product to the Product List
[productList addObject:product];

// CheckoutInitiated Constructor Call
-(void)trackCheckOutInitiated:(CheckOutInitiated*) checkOutInitiated;

  • Mandatory parameters (Checkout Initiated):         
    • User Id – Unique User Identifier
    • Total Price – Sum of the prices of the products initiated for Checkout
    • productList – Array of the list of products initiated for Checkout
    • 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 (Checkout Initiated):        
    • Loyalty – Loyalty points applied on the Purchase
    • Overall Discount – Discount applied for the Purchase
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event
    • Payment Information availableYES or NO depending on the availability of the user’s Payment preferences, in your Application

Sample Code

// Example Longitude &amp;amp;amp; 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 CheckoutItem Constructor Call with the mandatory parameters
CheckoutItem *product =[[CheckoutItem alloc]initWithCheckoutItemIdentifier:@"123" productName:@"Targus Backpack" price:29.99 quantity:1 category:@"Bags"];

// Examples for other parameters passed for the CheckoutItem Class (These are optional)
  [product setBrand:@"Targus"];
  [product setProductDiscount:5.00];

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

// Example CheckoutInitiated Constructor Call with the mandatory parameters
CheckOutInitiated *checkoutInitiated =[[CheckOutInitiated alloc]initWithCheckOutInitiatedUserID:@"123" TotalPrice:29.99 Currency:currencyCode checkoutItemList:productList];

// Examples for other parameters passed for the CheckoutInitiated Class (These are optional)
  [checkoutInitiated setLoyalty:65.00];
  [checkoutInitiated setOverallDiscount:5.00];
  [checkoutInitiated setPageName:@”Purchase_summary”];
  [checkoutInitiated setPaymentInfoAvailable:YES];
  [checkoutInitiated setLocationLatitude:latitude longitude:longitude];

// trackCheckoutInitiated method call
 [[MTraction mTractionManager] trackCheckOutInitiated:checkOutInitiated];

5. Cart Abandoned Event

This is used to track the event that is triggered when the users remove products from the shopping cart within your Application.

You will need to call the below method to track the Cart Abandoned event in your Application.

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

// RemovedFromCartItem Constructor Call
-(id)initWithRemovedFromCartItemIdentifier:(NSString*)identifier productName:(NSString*)productName price:(float)price quantity:(short)quantity;

  • Mandatory parameters (Removed from Cart Item):         
    • Identifier – Unique Product Identifier
    • Product Name – Name of the Product
    • Price – Price of the Product
    • Quantity – Quantity of the Product being Purchased
  • Optional parameters (Removed from Cart Item):         
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
// Adding the product to the Product List
[productList addObject:product];

// RemovedFromCart Constructor Call
-(void)trackRemovedFromCart:(RemovedFromCart*) removedFromCart;

  • Mandatory parameters (Cart Abandoned):         
    • User Id – Unique User Identifier
    • Category – Product Category
    • Product List – Array of the list of products initiated for Checkout
    • 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 (Cart Abandoned):         
    • Brand – Brand Name of the Product
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude &amp;amp;amp; 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 RemovedFromCartItem Constructor Call with the mandatory parameters
RemovedFromCartItem *product =[[RemovedFromCartItem alloc]initWithRemovedFromCartItemIdentifier:@"12345" productName:@"Targus Backpack price:29.99 quantity:1];

// Examples for other parameters passed for the RemovedFromCartItem Class (These are optional)
[product setBrand:@"Targus"];
[product setProductDiscount:5.00];

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

// Example RemovedFromCart Constructor Call with the mandatory parameters
RemovedFromCart *removedFromCart = [[RemovedFromCart alloc]initWithRemovedFromCartUserID:@"123" Category:@"Bags" Currency:currencyCode removedFromCartItem:productList];

// Examples for other parameters passed for the RemovedFromCart Class (These are optional)
[removedFromCart  setBrand:@”Targus”];
[removedFromCart  setProductDiscount:5.00];
[removedFromCart  setPageName:@”Purchase_summary”];
[removedFromCart setLocationLatitude:latitude longitude:longitude];

// trackRemoveFromCart method call
[[MTraction mTractionManager] trackRemovedFromCart:removedFromCart];

6. Return Order Event

This is used to track the Return Order event triggered when an user has completed a return product request on the Application.

You will need to call the below method to track the Order Return event in your Application.

// Product List Array Definition

NSMutableArray *productList=[[NSMutableArray alloc] init];

// Product Constructor Call

-(void)trackReturnOrder:(ReturnOrder*) returnOrder;
  • 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 (Removed from Cart Item):        
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
    • Category – Product Category
    • Model – Product Model
    • Product.ProductState.XXX – XXX can take any of the predefined values[NEW or USED]

// Adding product to the product list

NSMutableArray *productList=[[NSMutableArray alloc] init];

// Return Order  Constructor Call

-(void)trackReturnOrder:(ReturnOrder*) returnOrder;

  • Mandatory parameters (Return Order):         
    • User Id – Unique User Identifier
    • Category – Product Category
    • Identifier – Unique Event Identifier
    • Product Name – Name of the Product
    • Refund Amount – Amount to be refunded for the product
    • Quantity – Quantity of the product requested for refund
    • 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 (Return Order):         
    • Brand – Brand Name of the Product
    • Transaction Id – Transaction Identifier of the order returned
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude &amp;amp;amp; Latitude code (Long / Lat is optional)
#import <CoreLocation/CoreLocation.h>
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
 
  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:@"123" productName:@"Targus Backpack" price:29.99 quantity:1];

// Examples for other parameters passed for the Product Class (These are optional)
  [product1 setBrand:@"Targus"];
  [product1 setProductDiscount:5.00];
  [product1 setCategory:@"Bags"];
  [product1 setModel:@"z001"];
  [product1 setProductState:NEW];


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

// Example ReturnOrder Constructor Call with the mandatory parameters for single Product
ReturnOrder *returnOrder = [[ReturnOrder alloc]initWithReturnOrderUserID:nil Currency:currencyCode transactionId:nil RefundAmount:45.75 Product:product1];.
// Example ReturnOrder Constructor Call with the mandatory parameters for Multiple Product
ReturnOrder *returnOrder = [[ReturnOrder alloc]initWithReturnOrderUserID:@”123” Currency:currencyCode transactionId:@”456” refundAmount:129.99 ProductList:productList];
    
    [returnOrder setPageName:nil];
    [returnOrder setLocationLatitude:0 longitude:0];
    
    [[MTraction mTractionManager]trackReturnOrder:returnOrder];


7. Product Compare Event

This is used to track the product comparison event to let the users compare different products in the Application.

You will need to call the below method to track the Product Compare event in your Application.

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

// ProductComparedItem Constructor Call
-(id)initWithProductComparedItemIdentifier:(NSString*)identifier productName:(NSString*)productName price:(float)price;

  • Mandatory parameters (Product Compared Item):         
    • Identifier – Unique Product Identifier
    • Product Name – Name of the Product
    • Price – Price of the Product
  • Optional parameters (Product Compared Item):         
    • Brand – Brand Name of the Product
    • Product Discount – Discount applied for the Product
    • Tier – Class of the Product
// Adding the product to the Product List
[productList addObject:product];

// ProductCompared Constructor Call
-(void)trackProductCompared:(ProductCompared*) productCompared;

  • Mandatory parameters (Product Compared):         
    • User Id – Unique User Identifier
    • Product List – Array of the list of products initiated for Checkout
  • Optional parameters (Product Compared):         
    • Category – Product Category
    • Page Name – Page that triggered the Event
    • Location – Geolocation of the Event

Sample Code

// Example Longitude &amp;amp; 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;
  }
}

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

// Example ProductComparedItem Constructor Call with the mandatory parameters
 ProductComparedItem *product =[[ProductComparedItem alloc]initWithProductComparedItemIdentifier:@"12345" productName:@"Targus Backpack” price:29.99];

// Examples for other parameters passed for the ProductComparedItem Class (These are optional)
 [product setBrand:@"Targus"];
 [product setProductDiscount:5.00];
 [product setTier:@"Bags for Macbook"];

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

 // Example ProductCompared Constructor Call with the mandatory parameters
ProductCompared *productCompared =[[ProductCompared alloc]initWithProductComparedUserId:@"123" productComparedItem:productList];

// Examples for other parameters passed for the ProductCompared Class (These are optional)
 [productCompared setCategory:@”Bags”];
 [productCompared setPageName:@”Compare Products”];
 [productCompared setLocationLatitude:latitude longitude:longitude];

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

How can we help?