You can retrieve referral data attached to the Smart Link when:
The app is launched for a first time after being installed by clicking on the GetSocial Smart Link.
The app was opened by clicking on the GetSocial Smart Link.
The code below show how to do it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
GetSocial.getReferralData(newFetchReferralDataCallback(){@OverridepublicvoidonSuccess(@NullableReferralDatareferralData){if(referralData!=null){StringnavigationPath=(String)referralData.getLinkParams().get("$custom_path");// predefined keyStringcustomValue1=(String)referralData.getLinkParams().get("custom_key_1");// custom keybooleanisGuaranteedMatch=referralData.isGuaranteedMatch();// added metadataToast.makeText(MainActivity.this,"App started with referral data: "+referralData,Toast.LENGTH_LONG).show();}else{Toast.makeText(MainActivity.this,"No referral data found",Toast.LENGTH_LONG).show();}}@OverridepublicvoidonFailure(GetSocialExceptionerror){Toast.makeText(MainActivity.this,"Failed to retrieve referral data, error: "+error,Toast.LENGTH_LONG).show();}});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
GetSocial.getReferralData(object: FetchReferralDataCallback{overridefunonSuccess(referralData:ReferralData?){if(referralData!=null){valnavigationPath=referralData.linkParams["\$custom_path"]// predefined keyvalcustomValue1=referralData.linkParams["custom_key_1"]// custom keyvalisGuaranteedMatch=referralData.isGuaranteedMatch// added metadataprintln("App started with referral data: ${referralData}")}else{println("No referral data found")}}overridefunonFailure(exception:GetSocialException){println("Failed to retrieve referral data, error: ${exception.message}")}})
1
2
3
4
5
6
7
8
9
10
11
12
13
[GetSocialreferralDataWithSuccess:^(GetSocialReferralData*_NullablereferralData){if(referralData!=nil){NSString*navigationPath=[referralDatalinkParams][@"$custom_path"];// predefined keyNSString*customValue1=[referralDatalinkParams][@"custom_key_1"];// custom keyBOOLisGuranteedMatch=[referralDataisGuaranteedMatch];// added metadataNSLog(@"App started with referral data: %@",referralData);}else{NSLog(@"No referral data found");}}failure:^(NSError*_Nonnullerror){NSLog(@"Failed to retrieve referral data, error: %@",error.description);}];
1
2
3
4
5
6
7
8
9
10
11
12
13
GetSocial.referralData(success:{referralDatainguardletreferralData=referralDataelse{print("No referral data found")return}letnavigationPath=referralData.linkParams["$custom_path"]// predefined keyletcustomValue1=referralData.linkParams["custom_key_1"]// custom keyletisGuranteedMatch:Bool=referralData.isGuaranteedMatch// added metadataprint("App started with referral data: \(referralData)")},failure:{errorinprint("Failed to retrieve referral data, error: \(error)")})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
GetSocial.GetReferralData(onSuccess:(referralData)=>{if(referralData!=null){stringnavigationPath=(string)referralData.LinkParams["$custom_path"];// predefined keystringcustomValue1=(string)referralData.LinkParams["custom_key_1"];// custom keyboolisGuranteedMatch=referralData.IsGuaranteedMatch;// added metadataDebug.Log("App started with referral data: "+referralData);}else{Debug.Log("No referral data found");}},onFailure:(error)=>Debug.LogError("Failed to retrieve referral data, error: "+error.Message));
1
2
3
4
5
6
7
8
9
10
11
12
13
GetSocial.getReferralData().then((referralData)=>{if(referralData==null){console.log('Referral data','No referral data found.');}else{constnavigationPath=referralData.linkParams['$custom_path'];// predefined keyconstcustomValue1=referralData.linkParams['custom_key_1'];// custom keyconstisGuaranteedMatch=referralData.isGuaranteedMatch;// added metadataconsole.log('Referral data','App started with referral data: '+JSON.stringify(referralData));}},(errorMessage)=>{console.log('Failed to retrieve referral data',errorMessage);});
Whitelist Test Devices
To get the install attribution on every install you have to whitelist your testing devices on the GetSocial Dashboard.
For more information check Whitelist Test Devices.
Using GetSocial data API you can retrieve the list of users who installed application from the invitations sent by current user:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
finalReferralUsersQueryquery=ReferralUsersQuery.allUsers();// to return users only for a specific event:// final ReferralUsersQuery query = ReferralUsersQuery.usersForEvent("event");GetSocial.getReferredUsers(query,newCallback<List<ReferralUser>>(){@OverridepublicvoidonSuccess(List<ReferralUser>result){// process referred users}@OverridepublicvoidonFailure(GetSocialExceptionexception){// handle error}});
1
2
3
4
5
6
7
8
9
10
11
12
valquery=ReferralUsersQuery.allUsers()// to return users only for a specific event:// val query = ReferralUsersQuery.usersForEvent("event")GetSocial.getReferredUsers(query,object: Callback<List<ReferralUser>>{overridefunonSuccess(result:List<ReferralUser>){// process referred users}overridefunonFailure(exception:GetSocialException){// handle error}})
1
2
3
4
5
6
7
8
GetSocialReferralUsersQuery*query=[GetSocialReferralUsersQueryallUsers];// to return users only for a specific event:// GetSocialReferralUsersQuery* query = [GetSocialReferralUsersQuery usersForEvent:@"event";[GetSocialreferredUsersWithQuery:querysuccess:^(NSArray<GetSocialReferralUser*>*_NonnullreferrerUsers){// process referred users}failure:^(NSError*_Nonnullerror){// handle error}];
1
2
3
4
5
6
7
8
9
letquery=GetSocialReferralUsersQuery.allUsers()// to return users only for a specific event:// let query = GetSocialReferralUsersQuery.usersForEvent("event")letquery=GetSocialReferralUsersQuery.allUsers()GetSocial.referredUsers(with:query,success:{referralUsersin// process referred users},failure:{errorin// handle error})
1
2
3
4
5
6
7
8
9
varquery=ReferralUsersQuery.AllUsers();// to return users only for a specific event:// var query = ReferralUsersQuery.UsersForEvent("event");GetSocial.GetReferredUsers(query,referralUsers=>{// process referred users},error=>{// handle error});
1
2
3
4
5
6
7
8
9
10
GetSocial.getReferredUsers().then((referredUsers)=>{if(referredUsers.length>0){// current user invited others to the appconsole.log('Referred Users',JSON.stringify(referredUsers));}else{console.log('Referred Users','No referred users.');}},(errorMessage)=>{console.log('Failed to retrieve ReferredUsers, error: ',errorMessage);});
ReferralUser object contains user details, including eventDate, which is the date when a referral event happened to the user.
This way, for example, you can reward your users for inviting other users:
If ReferralUser object event is install and eventDate value is after reward check date, you can give the reward.
If you’re doing the reward based on the number of referred users, you probably want to check reinstall attribute in eventData, which means that it’s not the first install on this device.
If you need absolutely guarantee to install is 100% genuine, you want to use installSuspicious flag in eventData. It may be useful if you have any real money rewarding in your application.
In addition to the default install referrer, you can set the referrer manually as well:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
finalStringreferrerId=...// referrer user idfinalStringevent=...// eventMap<String,String>customData=...// any custom dataGetSocial.setReferrer(referrerId,event,customData,newCompletionCallback(){@OverridepublicvoidonSuccess(){// referrer information is set}@OverridepublicvoidonFailure(GetSocialExceptionexception){// handle error}});
1
2
3
4
5
6
7
8
9
10
11
12
valreferrerId=...// referrer user idvalevent=...// eventvalcustomData:Map<String,String>=...// any custom dataGetSocial.setReferrer(referrerId,event,customData,object:CompletionCallback{overridefunonSuccess(){// referrer information is set}overridefunonFailure(exception:GetSocialException){// handle error}})
1
2
3
4
5
6
7
8
9
NSString*referrerId=...// referrer user idNSString*event=...// eventNSDictionary*customData=...// any custom data[GetSocialsetReferrerWithId:referrerIdevent:eventcustomData:customDatasuccess:^(){// referrer information is set}failure:^(NSError*_Nonnullerror){// handle error}];
1
2
3
4
5
6
7
8
9
10
11
12
13
letreferredId=...// referrer user idletevent=...// eventletcustomData=...// any custom dataGetSocial.setReferrerWithId(referredId,event:event,customData:customData,success:{// referrer information is set},failure:{errorin// handle error})
1
2
3
4
5
6
7
8
9
varreferrerId=...// referrer user idvarevent=...// eventvarcustomData=...// any custom dataGetSocial.SetReferrer(referrerId,event,customData,()=>{// referrer information is set},(error)=>{// handle error});
You can retrieve the list of users who referred the current user to either install the application or take certain action in your application.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
finalReferralUsersQueryquery=ReferralUsersQuery.allUsers();// to return users only for a specific event:// final ReferralUsersQuery query = ReferralUsersQuery.usersForEvent("event");GetSocial.getReferrerUsers(query,newCallback<List<ReferralUser>>(){@OverridepublicvoidonSuccess(List<ReferralUser>result){// process referrer users}@OverridepublicvoidonFailure(GetSocialExceptionexception){// handle error}});
1
2
3
4
5
6
7
8
9
10
11
12
valquery=ReferralUsersQuery.allUsers()// to return users only for a specific event:// val query = ReferralUsersQuery.usersForEvent("event")GetSocial.getReferrerUsers(query,object: Callback<List<ReferralUser>>{overridefunonSuccess(result:List<ReferralUser>){// process referrer users}overridefunonFailure(exception:GetSocialException){// handle error}})
1
2
3
4
5
6
7
8
GetSocialReferralUsersQuery*query=[GetSocialReferralUsersQueryallUsers];// to return users only for a specific event:// GetSocialReferralUsersQuery* query = [GetSocialReferralUsersQuery usersForEvent:@"event";[GetSocialreferrerUsersWithQuery:querysuccess:^(NSArray<GetSocialReferralUser*>*_NonnullreferrerUsers){// process referrer users}failure:^(NSError*_Nonnullerror){// handle error}];
1
2
3
4
5
6
7
8
9
letquery=GetSocialReferralUsersQuery.allUsers()// to return users only for a specific event:// let query = GetSocialReferralUsersQuery.usersForEvent("event")letquery=GetSocialReferralUsersQuery.allUsers()GetSocial.referrerUsers(with:query,success:{referralUsersin// process referrer users},failure:{errorin// handle error})
1
2
3
4
5
6
7
8
9
varquery=ReferralUsersQuery.AllUsers();// to return users only for a specific event:// var query = ReferralUsersQuery.UsersForEvent("event");GetSocial.GetReferrerUsers(query,referralUsers=>{// process referrer users},error=>{// handle error});