Event Tracking

Event Tracking is a technique to track actions that a user performs while surfing through a website or while navigating through an app. InviteReferrals tracks users’ actions such as signing up to a brand via its app or its website, installing an organization’s application, finalizing a purchase or a sale etc. Consequently, InviteReferrals records these tracked actions as events which can in turn be configured as predefined conditions to offer rewards. In other words, when a user performs a specific action or event which has been pre-configured as a condition or prerequisite to gain a particular reward, then that specific user is recompensed with that reward.

InviteReferrals track at each and 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 own API and want to send data for different events to your server. You will receive the tracking callback responses to either success or failure. Read this informative guide to know the formats to track events.

Tracking Events

Implement the method mentioned below in order to track event(s):

InviteReferralsApi.getInstance(activityContext).tracking(IREventData.Builder eventInfo, IRUserData.Builder userInfo);
InviteReferralsApi.getInstance(activityContext).tracking(IREventData.Builder eventInfo, IRUserData.Builder userInfo)

Parameters

ParameterDescriptionValue
setEventName (string)InviteReferrals provide events which you can pass in the code to track conversions and accordingly reward the customers.sale, register, install, whatsapp, share
setOrderID (string)order id of the customerABXHXXXXX
setPurchaseValue (int)Total purchased amount of the event10000
setReferCode (string)referral code given by the referrer to his friend to make sale so that he gets the incentive.MARCXX
setUniqueCode (string)
setUserName (string)customer's nameabc
setUserEmail (string)customer's email[email protected]
setUserMobile (string)customer's mobile9999999999
setCustomValueOne (string)Any extra data you wanted to receivemumbai

The examples for install/register/sale events are mentioned below. You can also implement custom events using these formats according to your requirements.

A. SALE EVENT

IREventData.Builder eventInfo = new IREventData.Builder();
eventInfo.setEventName("sale");
eventInfo.setOrderID(“[email protected]”);
eventInfo.setPurchaseValue(20);
eventInfo.setReferCode(null);
eventInfo.setUniqueCode("");
eventInfo.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventInfo, null);
val eventData = IREventData.Builder();
eventData.setEventName("sale");
eventData.setOrderID(“[email protected]”);
eventData.setReferCode(null);
eventData.setPurchaseValue(20);
eventData.setUniqueCode("");
eventData.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventData, null);

B. INSTALL EVENT

IREventData.Builder eventInfo = new IREventData.Builder();
eventInfo.setEventName("install");
eventInfo.setOrderID(null);
eventInfo.setPurchaseValue(0);
eventInfo.setReferCode(null);
eventInfo.setUniqueCode(null);
eventInfo.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventInfo, null);
val eventData = IREventData.Builder();
eventData.setEventName("install");
eventData.setOrderID(null);
eventData.setPurchaseValue(0);
eventData.setReferCode(null);
eventData.setUniqueCode(null);
eventData.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventData, null);

C. REGISTER EVENT

IREventData.Builder eventInfo = new IREventData.Builder();
eventInfo.setEventName("register");
eventInfo.setOrderID(“[email protected]);
eventInfo.setPurchaseValue(20);
eventInfo.setReferCode(null);
eventInfo.setUniqueCode(null);
eventInfo.build();

IRUserData.Builder userInfo = new IRUserData.Builder();
userInfo.setUserName(“tom”);
userInfo.setUserEmail(“[email protected]”);
userInfo.setUserMobile(“9999999999”);
userInfo.setCustomValueOne("product789");
userInfo.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventInfo, userInfo);
val eventData = IREventData.Builder();
eventData.setEventName("register");
eventData.setOrderID(“[email protected]);
eventData.setPurchaseValue(20);
eventData.setReferCode(null);
eventData.setUniqueCode(null);
eventData.build();

val userData = IRUserData.Builder();
userData.setUserName(“tom”);
userData.setUserEmail(“[email protected]”);
userData.setUserMobile(“9999999999”);
userData.setCustomValueOne("product789");
userData.build();

InviteReferralsApi.getInstance(activityContext).tracking(eventData, userData);

You can also get a tracking() response in callback by implementing the function mentioned below: -

InviteReferralsApi.getInstance(activityContext).onEventTrack(new IRTrackingCallback() {
     @Override
     public void onEventHit(JSONObject response) {
          //do your task here
     }
});
InviteReferralsApi.getInstance(activityContext).onEventTrack(object : IRTrackingCallback {
    override fun onEventHit(p0: JSONObject?) {
        //do your task here
    }
})

Tracking Callback will provide responses to either failure or success.

In case of failure, you will get: -

{
   "eventName":"register",
   "response":{
      "Authentication":"fail",
      "conversion_details":{
         "conversion":"fail",
         "Error":"Data not found",
         "ErrorType":"2"
      }
   }
}

In case of success, you will get: -

{
  "eventName":"register",
  "response":{
     "bid":"46287",
     "bid_e":"EF2B93611671E38CB40FCB460A07C46D",
     "Authentication":"success",
     "conversion_details":{
        "campaignID":"27894",
        "event":"register",
        "conversion":"success",
        "referrer_name":"Jack",
        "referrer_email":"[email protected]",
        "referrer_mobile":"0000000000",
        "referrer_email_org":"[email protected]",
        "referee_name":"Jack90",
        "referee_email":"[email protected]",
        "referee_mobile":"0000000099",
        "referee_android_id":"2cce7afd59743d9b",
        "referee_ios_ifa":"",
        "referee_email_org":"[email protected]",
        "orderID":"[email protected]",
        "purchaseValue":10,
        "order_custom_val":"",
        "ir_referrer_code":"MGB9Q7HR",
        "unique_code":""
     }
  }
}

All the error types along with their corresponding error messages that are used in the callback, in case of failure response, are as follows: -

Error MessageError TypeScenarioNote
Data not found2In case when data not found
Invalid Authentication4if something went wrong and the API authentication failed or network error
Invalid Account5In case of wrong account credential passed in AndroidManifest file (ie. BrandID and EncryptionKey)
Conversion not eligible6In 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 missing7Parameter missing, orderID or eventName cannot be empty or nullIn case the Event name is null or empty, in the 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 eligible9In case of Install or register event, if that event already tracked or the tracking conditions are not eligible
No REFERRER found10When no referrer is available.