Skip to content

Reward Notifications

Ram edited this page Aug 4, 2016 · 62 revisions

Check for Referrer/Friend Rewards and Conversion Notifications

Campaign Rewards can be configured in the AppVirality Dashboard to be reported as either a client-side or server-side callbacks.

Option 1 - Server-side Callbacks(Webhooks)

Reward notifications through Web hooks are user-defined HTTP post backs which are triggered on pre-defined events to receive the reward/event information. Each web hook expects a HTTP URL to deliver payload (web hook data). To configure the Web hook URLs navigate to "Notifications" by clicking on left menu and then "Web Hooks" tab.

NOTE: Web hook call expects HTTP 200 OK Status Code as response. In case of any failure, the re-send call attempt is made for a maximum of 5 times.

Alt Webhook Configuration

Secure Key – This is a key parameter that is set by you to identify AppVirality as an authorized server to call the web hook.

1) On Conversion Success (Conversion Event URL)

This callback is received when a successful Conversion Event is triggered. The payload contains information regarding the rewards received by Referrer and Friend.

NOTE: Conversion webhook will get fired immediately on successful conversion. Fraud check will not happen by the time this webhook get's fired. Please use Check Reward status API before rewarding the users.

Method POST
Content-Type application/json

#####Payload Parameters:

  • securekey — Secure Key which is set for the Campaign post backs, get this from Dashboard > Edit Campaign
  • campaignid — Unique Campaign ID
  • campaignname — Name of the Campaign
  • eventname — Install, Signup, Transaction & Any defined Custom Events
  • extrainfo — Info provided during the Conversion Event. Data will be Uri encoded.
  • friend — Object that consists Friend details along with his reward information
    • participantid — Campaign Participant ID of Friend
    • emailid — Email of the Friend
    • name — Name of the Friend
    • storeuserid — This is the ID with which you recognize the user uniquely in your store.
    • rewardid — Reward ID, to Track the Reward and Distribution
    • rewarddtlid — Reward detail ID
    • reward_type — Type of Reward (Coupon, InstoreCredits,Other)
    • rewarded_date — Reward Initiated Date (eg: 27-Mar-2015)
    • amount — amount of money to reward (null when non-monetary incentive is used)
    • reward_unit — Currency Unit of the Reward
    • reward_description — Description provided for reward in case of reward type Other.
    • couponcode — Coupon code dispatched to Friend as a reward. Only when the Reward type is coupon.
    • expires — Coupon expiry date.
    • platform — User platform (Android, iOS, Android, Web, Unknown).
  • referrer — Object that consists Referrer details along with his reward information
    • participantid — Campaign Participant ID of Referrer
    • emailid — Email of the Referrer
    • name — Name of the Referrer
    • storeuserid — This is the ID with which you recognize the user uniquely in your store.
    • rewarddtlid — Reward detail ID
    • rewarded_date — Reward Initiated Date (eg: 27-Mar-2015)
    • amount — amount of reward
    • reward_unit — Currency Unit of the Reward
    • reward_description — Description provided for reward in case of reward type Other.
    • reviewperiod — No of days set as Review Period for Campaign.
    • platform — User platform (Android, iOS, Android, Web, Unknown).

#####Sample Payload

{
 "securekey":"samplessecurekey",
 "success":true,
 "campaignid":"285",
 "campaignname":"iReff",
 "eventname":"Install",
 "extraInfo":null,
 "friend":{
    "participantid":"195644",
    "emailid":"frnd.rj990@gmail.com",
    "name":null,
    "storeuserid":null,
    "rewardid":"47",
    "rewarddtlid":"9340",
    "reward_type":"InstoreCredits",
    "rewarded_date":"27-Mar-2015",
    "amount":"20",
    "reward_unit":"Rs",
    "reward_description":null,
    "couponcode":null,
    "expires":null,
    "platform":"Android"},
 "referrer":{
    "participantid":"195640",
    "emailid":"ref.rj@hotmail.com",
    "name":null,
    "storeuserid":null,
    "rewarddtlid":"9339",
    "rewarded_date":"27-Mar-2015",
    "amount":"10",
    "reward_unit":"Rs",
    "reward_description":null,
    "reviewperiod":"0",
    "platform":"iOS"},
 "message":null
}

2) On Rewarding Friend (Friend Reward WebHook URL)

Triggered when a friend is rewarded. The web hook data includes details of friend who was rewarded along with referrer details (whom he/she is referred by). Input parameters received are same as on Conversion.

Method POST
Content-Type application/json

#####Sample Payload

{
 "securekey":"samplessecurekey",
 "success":true,
 "campaignid":"285",
 "campaignname":"iReff",
 "eventname":"Install",
 "extraInfo":null,
 "friend":{
    "participantid":"195644",
    "emailid":"frnd.rj990@gmail.com",
    "name":null,
    "storeuserid":null,
    "rewardid":"47",
    "rewarddtlid":"9340",
    "reward_type":"InstoreCredits",
    "rewarded_date":"27-Mar-2015",
    "amount":"20",
    "reward_unit":"Rs",
    "reward_description":null,
    "couponcode":null,
    "expires":null,
    "platform":"Android"},
 "referrer":{
    "participantid":"195640",
    "emailid":"ref.rj@hotmail.com",
    "name":null,
    "storeuserid":null,
    "rewarddtlid":"9339",
    "rewarded_date":"27-Mar-2015",
    "amount":"10",
    "reward_unit":"Rs",
    "reward_description":null,
    "reviewperiod":"0",
    "platform":"iOS"},
 "message":null
}

3) On Rewarding Referrer (Referrer Reward WebHook URL)

Triggers on referrer meeting the eligibility criteria, but for Coupons case it is triggered after rewarding the user. The payload contains reward details which is sent to the referrer.

NOTE: This webhook gets called with a delay of 5 minutes, as the background service checks the user rewards against the redemption cap for every 5 minutes. This web-hook get's triggered only if the referrer balance >= to redemption cap in case of "Instore Credits".

Method POST
Content-Type application/json

#####Payload Parameters:

  • securekey — Secure Key which is set for the Campaign post backs, get this from Dashboard > Edit Campaign
  • emailid — Email of the Referrer
  • name — Name of the Referrer
  • storeuserid — This is the ID with which you recognize the user uniquely in your store.
  • campaignid — Unique Campaign ID
  • campaignname — Name of the Campaign
  • participantid — Campaign Participant ID of Referrer
  • rewardid — Reward ID, to Track the Reward and Distribution
  • reward_type — Type of Reward (Coupon, InstoreCredits,Other)
  • rewarded_date — Reward Distributed Date (eg: 27-Mar-2015)
  • amount — amount of money to reward (null when non-monetary incentive is used)
  • reward_unit — Currency Unit of the Reward
  • reward_description — Description provided for reward in case of reward type Other.
  • couponcode — Coupon code dispatched to Friend as a reward. Only when the Reward type is coupon.
  • expires — Coupon expiry date.
  • platform — User platform (Android, iOS, Android, Web, Unknown).
  • rewarddetails — Rewards break down
    • rewarddtlid — Reward detail ID
    • amount — amount of reward
    • rewarded_date — Reward Initiated Date (eg: 27-Mar-2015)

#####Sample Payload

{
 "securekey":"samplessecurekey",
 "emailid":"ref.rj@hotmail.com",
 "name":null,
 "storeuserid":null,
 "campaignid":"285",
 "campaignname":"iReff",
 "participantid":"195640",
 "rewardid":"48",
 "reward_type":"InstoreCredits",
 "rewarded_date":"27-Mar-2015",
 "amount":"10",
 "reward_unit":"Rs",
 "reward_description":null,
 "couponcode":null,
 "expires":null,
 "platform":"iOS",
 "rewarddetails":[{
     "rewarddtlid":"9339",
     "amount":"5",
     "rewarded_date":"27-Mar-2015"},
     {
     "rewarddtlid":"9340",
     "amount":"5",
     "rewarded_date":"27-Mar-2015"}]
}
Setup and Testing web-hook calls
  • Visit http://requestb.in/ and click Create a RequestBin.
  • Copy the URL you are given.
  • Open AppVirality Dashboard and navigate to Add/Edit Campaign Page 2nd Step.
  • Select "Server Side (Webhook URL's)" in "Reward Notifications" section.
  • Paste your RequestBin URL and save.
  • Now you will receive the expected payload Conversion Event.
  • After finishing the implementation on your site change RequestBin URL to the live URL on your site.

Option 2 - client-side callbacks(In App Notification)

If configured for client-side callbacks, code similar to the following can be added in your Application. This is typically done by extending Android’s Application class.Please extend the Application class in your App.

Example:


public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    //Add Referrer/Friend Rewards Notifications logic here

NOTE: Make sure to add the fully qualified name of the Application sub-class to the android:name attribute in the applications manifest.

1) Check for Friend Reward :

Add the following code block in your Application class onCreate() method to get notified when a friend converts (Conversion could be Install / Signup / Purchase etc according to reward rules configured in your campaign).


        
      		//Check for FriendReward, Listner will get called if there is any Friend Reward.
		AppviralityAPI.checkFriendReward(getApplicationContext(), new AppviralityAPI.FriendRewardListner() {			
			@Override
			public void onFriendReward(JSONObject friendRewardListner) {
				try {
					//Use the following code block 
					//to mark the friend reward as Distributed if the reward type is in-store credits
					//to approve the dynamic coupon if the reward type is Dynamic Coupon.
					//Example: You will call this method after rewarding the user with In-store credits(wallet balance).
					/*JSONObject acceptedList = new JSONObject();
					acceptedList.put("rewardid", friendRewardListner.getString("rewardid"));
					acceptedList.put("reward_type", friendRewardListner.getString("reward_type"));	
					acceptedList.put("status", "Distribute");				
					// add this call after accepting the reward to confirm.
					AppviralityAPI.acceptReward(new JSONObject().put("rewards", new JSONArray().put(acceptedList)));*/
					Log.d("AppviralityAPI", "Friend Reward Details : " + friendRewardListner);
				}
				catch(Exception e) {
					e.printStackTrace();
				}					
			}
		});

#####Sample Payload:


{"participantid":"76608","rewardid":"3238","emailid":"user@email.com","name":null,"storeuserid":null,"reward_type":"Coupon","rewarded_date":"10-Jan-2015","amount":"50","reward_unit":"Rs","reward_description":null,"couponcode":"XRVC45T","expires":"14-May-2015"}

2) Conversion Success Notification :

Add the following code block in your Application class onCreate() method to get notified on reward conversion event success.


        
        AppviralityAPI.onSuccessfullConversion(getApplicationContext(), new ConversionEventListner() {			
			@Override
			public void onConversionEventSuccess(JSONObject postdata) {
				Log.d("", "user SaveConversionEvent result : " + postdata);				
			}
		});

#####RewardDetails JSON Object Parameters:

  • success — This will be true, If there is a reward
  • emailid — Email of the User
  • name — Name of the User
  • storeuserid — This is the ID with which you recognize the user uniquely in your store.
  • rewards — Rewards Array
    • campaignid — Unique Campaign ID
    • campaignname — Name of the Campaign
    • participantid — Campaign Participant ID
    • rewardid — Reward ID , to Track the Reward and Distribution
    • reward_type — Type of Reward (Coupon, InstoreCredits,Other)
    • rewarded_date — Reward Initiated Date
    • amount — amount of money to reward (null when non-monetary incentive is used)
    • reward_unit — Currency Unit of the Reward
    • reward_description — Verbal Reward description in the case of Reward type – Other.
    • couponcode — Coupon code received by Referrer as a reward. Only in case when Reward equals to coupon.
    • expires — Coupon expiry date.

Sample Referrer Reward Payload:

{
   "success":true,
   "emailid":null,
   "name":null,
   "storeuserid":null,
   "rewards":[
      {
         "campaignid":"64",
         "campaignname":"campaign",
         "participantid":"76607",
         "rewardid":"3239",
         "reward_type":"Coupon",
         "rewarded_date":"10-Jan-2015",
         "amount":"50",
         "reward_unit":"Rs",
         "reward_description":null,
         "couponcode":"frdesfced",
         "expires":"5-Mar-2015"
      }
   ]
}

Reward Types:

InstoreCredits — monetary reward, certain amount of money will be added to customers account. Payment should be handled by the merchants’ payment systems.

Coupon — discount coupon is issued to customer. This type of incentives is handled by AppVirality.

Other — used when a campaign has a non-monetary reward like “Free T-shirt” or “One Month Free”. This should be handled on the merchant’s side. More information on the reward is specified in reward_description.

#####Sample Payload:

{"success":true,"campaignid":"64","campaignname":"campaign","eventname":"Install",
"friend":{"participantid":"76608","rewardid":"3238","emailid":"friend@email.com","name":null,"storeuserid":null,"reward_type":"Coupon","rewarded_date":"10-Jan-2015","amount":"50","reward_unit":"Rs","reward_description":null,"couponcode":"RXVYZYT","expires":"14-May-2015"},"referrer":{"rewardid":"3238","participantid":"76607","emailid":"referrer@email.com","name":"referrer name","storeuserid":null,"rewarded_date":"10-Jan-2015","amount":"50","reward_unit":"Rs","reward_description":null,"reviewperiod":"0"}}

Help on other topics:

Please have a look at our Wiki page

  1. Getting Started With AppVirality Android SDK Integration
  2. AppVirality API for referral Growth Hack
  3. How to Add Test Devices & Test Referral Program
  4. Using Custom Domain
  5. Init Callback | hasReferrer | getUserKey
  6. Using Referral Code & Referral Link
  7. [Optional] Exclude Premium Users
  8. [Optional] Dynamic Share Message
  9. [Optional] Remind Later Settings
  10. [Optional] To Whom and When to Show Growth Hack
  11. [Optional] Reward Notifications or Web-hook Configuration
  12. [Optional] Android Push Notification Configuration
  13. [Optional] Personalized Welcome Screen
  14. Referral Program on Apps having Login and Logout