Event Tracking

InviteReferrals tracks every step of the referral campaign, from shares to clicks to conversions such as registrations, sales, and mobile application installs. You can set up a webhook if you have your API and want data for different events to be sent to your server. You will receive the tracking call-back responses to either success or failure. Read this informative guide to know the formats to track events.

You can track the events (For example: Install / Register / Sale) by using the following method.

let eventData = IREventInfo()
eventData.eventName = "eventName"
eventData.orderID = "orderID"
// OrderID parameter will be treated as userID in case of event name is "register"

eventData.purchaseValue = 199
eventData.referrerCode = "referrerCode"
eventData.uniqueCode = "uniqueCode"
let userData = IRUserInfo()
userData.name = "customer Name"
userData.email = "customer email"
userData.mobileNo = "customer mobile no"
userData.subscriptionID = "customer subscriptionID"
userData.customValueOne = "1st custom Value"
userData.customValueTwo = "2nd custom Value"
InviteReferrals.sharedInstance().trackingforEventInfo(eventData, userInfo: userData)

Install:

let eventData = IREventInfo()
eventData.eventName = "install"

InviteReferrals.sharedInstance().trackingforEventInfo(eventData, userInfo: nil)

Register:

let eventData = IREventInfo()
eventData.eventName = "register"
eventData.orderID = "[email protected]"
// OrderID parameter will be treated as userID in case of event name is "register"
let userData = IRUserInfo()
userData.name = "Tom"
userData.email = "[email protected]"
userData.mobileNo = "9818XXXXXX"
userData.subscriptionID = nil
userData.customValueOne = "1st custom Value"
userData.customValueTwo = nil
InviteReferrals.sharedInstance().trackingforEventInfo(eventData, userInfo: userData)

Sale:

let eventData = IREventInfo()
eventData.eventName = "sale"
eventData.orderID = "asdf1234"
eventData.purchaseValue = 199
eventData.referrerCode = nil
eventData.uniqueCode = nil

let userData = IRUserInfo()
userData.name = "Tom"
userData.email = "[email protected]"
userData.mobileNo = "9818XXXXXX"
userData.subscriptionID = nil
userData.customValueOne = "1st custom Value"
userData.customValueTwo = nil
InviteReferrals.sharedInstance().trackingforEventInfo(eventData, userInfo: userData)
IREventInfo *eventData = [[IREventInfo alloc] init];
eventData.eventName = @"eventName";
eventData.orderID = @"orderID";
// OrderID parameter will be treated as userID in case of event name is "register"
eventData.purchaseValue = 199;
eventData.referrerCode = @"referrerCode";
eventData.uniqueCode = @"uniqueCode";

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"customer Name";
userData.email = @"customer email";
userData.mobileNo = @"customer mobile no";
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = @"2nd custom Value";

[[InviteReferrals sharedInstance] trackingforEventInfo: eventData userInfo: userData];

Install:

IREventInfo *eventData = [[IREventInfo alloc] init];
eventData.eventName = @"install";

[[InviteReferrals sharedInstance] trackingforEventInfo: eventData userInfo: nil];

Register:

IREventInfo *eventData = [[IREventInfo alloc] init];
eventData.eventName = @"register";
eventData.orderID = @"[email protected]";
// OrderID parameter will be treated as userID in case of event name is "register"
IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"Tom";
userData.email = @"[email protected]";
userData.mobileNo = @"9818XXXXXX";
userData.subscriptionID = nil
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = nil;
[[InviteReferrals sharedInstance] trackingforEventInfo: eventData userInfo: userData];

Sale:

IREventInfo *eventData = [[IREventInfo alloc] init];
eventData.eventName = @"sale";
eventData.orderID = @"asdf1234";
eventData.purchaseValue = 199;
eventData.referrerCode = nil;
eventData.uniqueCode = nil;

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"Tom";
userData.email = @"[email protected]";
userData.mobileNo = @"9818XXXXXX";
userData.subscriptionID = nil
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = nil;
[[InviteReferrals sharedInstance] trackingforEventInfo: eventData userInfo: userData];
ParameterDescriptionValue
Event_Name (String)InviteReferrals provides events which you can pass in the code to track conversions and accordingly reward the customers.sale, register, install, whatsapp, share
orderID (String)Order id or (userID for register event) of the customerABXHXXXX (for register tracking pass email / mobile)
purchaseValue (String)Total purchased amount of the event1000
email (String)Customer's email id[email protected]
mobile (String)Customer's mobile number9717XXXXXX
name (String)Name of the customer.Mike
referCode (String) [Optional]referral code given by the referrer to his friend to make a sale so that he gets the incentive.MARCXX
or
nil
uniqueCode (String) [Optional]unique code sent by the referrer to his friend to make a sale so that he gets the incentive.ASDFXXX
or
nil
isDebugMode (BOOL)It works only for install event tracking if you app is in development mode then for testing make it true and If App is on App Store you must pass isDebugMode = NO or false in swift in install tracking.true / false

If you want, you can also consider tracking method response callback, by using InviteReferralsDelegate in your app. Suppose you want to use this delegate in your ViewController, then add the delegate in your ViewController file.

class ViewController: UIViewController, InviteReferralsDelegate {
}
#import <UIKit/UIKit.h>
#import <InviteReferrals/InviteReferrals.h>

@interface ViewController : UIViewController <InviteReferralsDelegate>
@end

Now inside viewDidLoad() of your ViewController.swift file, call the following method to set the delegate.

override func viewDidLoad() {
      super.viewDidLoad()
      InviteReferrals.sharedInstance()?.delegate = self
}
- (void)viewDidLoad {
      [super viewDidLoad];
      [InviteReferrals sharedInstance].delegate = self;
}

Now you can implement the following function and here you will get the tracking event method callback on its compilation.

func inviteReferralsTrackingFinishedforEventInfo(_ trackingResponse: [AnyHashable : Any]!) {
print("Tracking event callback response =  \(trackingResponse!)")
}
-(void)InviteReferralsTrackingFinishedforEventInfo:(NSDictionary *)trackingResponse {
NSLog(@"Tracking event callback response = %@", trackingResponse);
}

This callback response will give you either a success or failure response based on the conversion validation rule as per your dashboard, setting some of the sample responses given below for your reference.

{
  "eventName" : "register",
  "response" : {
  "conversion_details" : {
      "referrer_custom_value_two" : "",
      "referee_ios_ifa" : "EB038FB0-XXXXXXXXXXXXXXXXXXXXXXXXX",
     "referee_mobile" : "",
     "referrer_name" : "Tom",
     "event_type" : 4,
     "referee_email_org" : "[email protected]",
     "referee_android_id" : "",
     "orderID" : "[email protected]",
     "purchaseValue" : "",
     "campaignID" : "21XXX",
     "referrer_coupon" : "",
     "referrer_custom_one" : "",
     "referrer_custom_two" : "",
     "ir_referrer_code" : "SHXXXXXX",
     "referrer_rank" : "",
     "referrer_email" : "[email protected]",
     "referrer_stats" : {
        "invites" : 7,
        "clicks" : "48",
        "converts" : "27"
      },
      "event" : "register",
      "conversion" : "pending",
     "referee_name" : "tom_2021XXXXXXXX",
     "order_custom_val" : "",
     "referrer_mobile" : "9598XXXXXX",
     "referee_coupon" : "",
     "referee_email" : "[email protected]ail.com",
     "referrer_email_org" : "[email protected]",
     "brandID" : "10XXX",
     "referrer_device" : "1",
     "unique_code" : "ASDFXXXXX",
     "referrer_custom_value" : ""
  },
  "Authentication" : "success",
  "bid_e" : "C2C3B406726C2FXXXXXXXXXXXXXX",
"bid" : "10XXX"
}
}
{
  "eventName" : "register",
  "response" : {
  "conversion_details" : {
      "conversion" : "Failed",
      "Error" : "Conversion not eligible because Referrer not found. Api not triggered.",
      "ErrorType" : 6
     },
  "Authentication" : "Failed"
  }
}

In case of the failure response, following are the error-type with error-messages used in the callback: -

Error MessageError TypeScenarioNote
Data not found 2 In case when data not found--
Invalid authentication 4 if something went wrong and the API authentication failed or network error--
Invalid account 5 In case of wrong account credential passed in AndroidManifest file (ie. BrandID and EncryptionKey)--
Conversion not eligible 6 In case a referrer is not found, that means the referral link was not clicked if the referrer shared the referral link. OR In case of referrerCode /uniqueCode the value for referrerCode / unique code is either nil or invalid--
Parameter missing 7 Parameter missing, orderID or eventName cannot be empty or nullIn case the Event name is null or empty, in callback response "eventName" key will not appear

Example : {"response":{"Authentication":"fail","conversion_details":{"conversion":"fail","Error":"Parameter missing, orderID or eventName cannot be empty or null","ErrorType":"7"}}}
Install already tracked or not eligible 9 In case of Install or register event if that event already tracked or the tracking conditions are not eligible--

Moreover, before you get started with event tracking, consider doing test event tracking for better understanding.