Event Tracking

TRACKING EVENTS

InviteReferrals track at each and every step of the referral campaign from shares to clicks to conversions such as registrations, sales, mobile application installs. You can set up a webhook if you have your own API and you want data for different events to be sent on 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.

Tracking Events

Implement the below method to track event(s):

InviteReferrals.tracking("Event_Name", orderID: "Order_ID", purchaseValue: "Purchase_Value", email: "EmailID", mobile: "MobileNo", name: "Name", referCode: "referralCode (OPTIONAL otherwise nil)", uniqueCode: "uniqueCode (OPTIONAL otherwise nil)", isDebugMode: true/false,  complitionHandler: nil);
[InviteReferrals tracking: @"Even_Name" orderID: @"ORDERID" purchaseValue:  @"Purchase Value"  email: @"EmailID" mobile: @"Mobile Number" name: @"Name" referCode: @" referrerCode (OPTIONAL otherwise nill)" uniqueCode: @"uniqueCode (OPTIONAL otherwise nill)" isDebugMode: YES/NO ComplitionHandler: nil];

You can track the events (For example: Install / Register / Sale) from the above method.

Read below the use cases

A. Install

InviteReferrals.tracking("install", orderID: nil, purchaseValue: nil, email: nil, mobile: nil, name: nil, referCode: nil, uniqueCode: nil, isDebugMode: true,  complitionHandler: nil)
[InviteReferrals tracking: @"install" orderID: nil purchaseValue: nil  email: nil mobile: nil name: nil referCode: nil uniqueCode: nil isDebugMode: NO ComplitionHandler: nil];

B. Register

InviteReferrals.tracking("register", orderID: "[email protected]", purchaseValue: nil, email: "[email protected]", mobile: "9818XXXXXX", name: "Tom", referCode: nil, uniqueCode: nil, isDebugMode: false,  complitionHandler: nil)
[InviteReferrals tracking: @"register" orderID: @"[email protected]" purchaseValue: nil  email: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" referCode: nil uniqueCode: nil isDebugMode: NO ComplitionHandler: nil];

C. Sale

InviteReferrals.tracking("sale", orderID: "23415", purchaseValue: "1499", email: "[email protected]", mobile: "9818XXXXXX", name: "Tom", referCode: nil, uniqueCode: nil, isDebugMode: false,  complitionHandler: nil);
[InviteReferrals tracking: @"sale" orderID: @"421789" purchaseValue:  @"1599"  email: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" referCode: nil uniqueCode: nil isDebugMode: NO ComplitionHandler: nil];

Parameter

Description

Value

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 customer

ABXHXXXX (for register tracking pass email / mobile)

purchaseValue
(String)

Total purchased amount of the event

1000

email
(String

Customer's email id

[email protected]

mobile
(String)

Customer's mobile number

9717XXXXXX

name
(String)

Name of the customer.

Mike

referCode
(String)

referral code given by the referrer to his friend to make a sale so that he gets the incentive.

MARCXX
or

[Optional]

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

You can also get a tracking method response callback, by using InviteReferralsDelegate in your app if you want to do so. 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 inviteReferralsTrackingFinishedforEventname(_ eventName: String?, withResponse trackingResponse: NSMutableDictionary?) {
print("Tracking result for event name '\(eventName ?? "")' with response \(trackingResponse!)")
}
(void)InviteReferralsTrackingFinishedforEventname:(NSString *)eventName withResponse:(NSMutableDictionary *)trackingResponse {
NSLog(@"Tracking result for event name %@ with response %@",eventName, 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.

Conversion Success

Conversion Failed

{
"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]",
"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 of Referrer not found. Api not triggered.",
"ErrorType" : 6
},
"Authentication" : "Failed"
}
}

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

Error Message

Error Type

Scenario

Note

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 null

In 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