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

Travel Applications – iOS

We have provided a list of Events with their example usage that can be integrated for Applications that belong to the Travel 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. Reservation Event

This is used to track the event triggered when an user has completed a Travel Booking on your Application.

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

[[MTraction mTractionManager]trackReservation:reservation];
-(void)trackReservation:(Reservation*) reservation;

  • Mandatory parameters (Reservation): 
    • User Id – Unique User Identifier
    • Category – Travel Category
    • Date From – Travel Booking starting date
    • Location From – Location from which the travel will start
    • Revenue – Revenue generated from this Reservation event
    • 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"] ;
      
    • Payment ModeCREDIT_CARD or DEBIT_CARD or NET_BANKING or GIFT_CARD or PAYMENT_WALLET
    • Transaction Id – Reservation Transaction Identifier
  • Optional parameters (Reservation): 
    • Identifier – Unique Event Identifier
    • Product Name – Name of the Travel Product
    • Date To – Travel Booking end date
    • Location To – Location from which the travel will start
    • Loyalty – Loyalty points applied on the booking
    • Class – Class of Travel
    • Brand – Brand information(if any) on the Travel booking
    • Discount – Discount applied for the Travel booking
    • 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 Dates to passed in as Optional parameters
NSString *dateFromStr = @"17/06/2016";
NSString *dateToStr = @"24/06/2016";
NSTimeZone *centralStandardTime = [NSTimeZone timeZoneWithAbbreviation:@"CST"];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
[dateFormatter setTimeZone:centralStandardTime];
NSDate *dateFrom = [dateFormatter dateFromString:dateFromStr];
NSDate *dateTo = [dateFormatter dateFromString:dateToStr];

// Example Constructor Call with the mandatory parameters
Reservation *reservation =[[Reservation alloc]initWithReservationUserID:@"123" Category:@"Flights" DateFrom:dateFrom LocationFrom:@"Singapore" Revenue:535.00 Currency:currencyCode PaymentMode:CREDIT_CARD TransactionId:@"123456"];

// Examples for other parameters passed with the event (These are optional)
  [reservation setIdentifier:@"SINDEL12301"];
  [reservation setProductName:@"SIN-DEL Flights"];
  [reservation setDateTo:dateTo];
  [reservation setLocationTo:@"New Delhi"];
  [reservation setLoyalty:850.00];
  [reservation setClass:@"economy"];
  [reservation setBrand:@"Singapore Airlines"];
  [reservation setDiscount:5.00];
  [reservation setPageName:@"Flight Itinerary"];
  [reservation setLocationLatitude:latitude longitude:longitude];

// trackAddToCart method call
[[MTraction mTractionManager]trackReservation:reservation];

2. Reservation Cancelled Event

This is used to track booking cancellation done by an user in a Travel Application.

YYou will need to call the below method to track the reservation cancelled event in your Application.

[[MTraction mTractionManager]trackCancelReservation:cancelReservation];
-(void)trackCancelReservation:(CancelReservation*) cancelReservation;

  • Mandatory parameters (Reservation Cancelled): 
    • User Id – Unique User Identifier
    • Category – Travel Category
    • Date From – Travel Booking starting date
    • Location From – Location from which the travel will start
    • Refund Amount – Amount to be refunded on cancellation of the Reservation
    • 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 (Reservation Cancelled): 
    • Identifier – Unique Event Identifier
    • Brand – Brand information(if any) on the Travel booking
    • Product Name – Name of the Travel Product
    • Date To – Travel Booking end date
    • Location To – Location from which the travel will start
    • Class – Class of Travel booking
    • Transaction Id – Unique Transaction Identifier of the Reservation
    • 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 Dates to passed in as Optional parameters
NSString *dateFromStr = @"17/06/2016";
NSString *dateToStr = @"24/06/2016";
NSTimeZone *centralStandardTime = [NSTimeZone timeZoneWithAbbreviation:@"CST"];
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
[dateFormatter setTimeZone:centralStandardTime];
NSDate *dateFrom = [dateFormatter dateFromString:dateFromStr];
NSDate *dateTo = [dateFormatter dateFromString:dateToStr];

// Example Constructor Call with the mandatory parameters
CancelReservation *cancelReservation =[[CancelReservation alloc]initWithCancelReservationUserID:@"123" Category:@"Hotels in India" DateFrom:dateFrom LocationFrom:@"Singapore" RefundAmount:300.00 Currency:currencyCode];

// Examples for other parameters passed with the event (These are optional)
  [cancelReservation setIdentifier:@"100001"];
  [cancelReservation setBrand:@"ITC Hotels"];
  [cancelReservation setProductName:@"ITC Sheraton New Delhi"];
  [cancelReservation setDateTo:dateTo];
  [cancelReservation setLocationTo:@"New Delhi”];
  [cancelReservation setClass:@"Business Suite"];
  [cancelReservation setTransactionId:@"789456123"];
  [cancelReservation setPageName:@"Cancel Booking"];
  [cancelReservation setLocationLatitude:latitude longitude:longitude];

// trackCancelReservation method call
 [[MTraction mTractionManager]trackCancelReservation:cancelReservation];

3. Travel Compare Event

This is used to track the Travel Itinerary Comparison event which lets the users compare various travel options available in the Application.

You will need to call the below method to track the Travel 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 Travel Product
    • Product Discount – Discount applied for the Travel booking
    • Tier – Class of Travel
// 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 – Category of the Travel
    • 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;
  }
}

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

// Example ProductComparedItem Constructor Call with the mandatory parameters
ProductComparedItem *product =[[ProductComparedItem alloc]initWithProductComparedItemIdentifier:@"12345" productName:@"SIN to DEL Return Air Tickets” price:800.00];

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

// 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:@”Flights”];
 [productCompared setPageName:@”Compare flights”];
 [productCompared setLocationLatitude:latitude longitude:longitude];

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

How can we help?