HomeAppVirality DocsAdvanced ConfigurationsUsing Referral Codes

Using Referral Codes

Having finished with your Integration for Android or iOS, you may now be looking at implementing a Referral Campaign driven by both: Code & Link.

AppVirality supports both referral code and referral link to attribute Friend/Referrer.

Referral program can be configured with 3 different attribution settings.

  • Link + Referral Code (default)
  • Only Referral Link
  • Only Referral Code

As mentioned above, the default settings employ Link + Code based attribution for your Referral program.

To choose any of the others, i.e. Only Referral Link or Only Referral Code based attribution for your Referral program, please mail to us at support@appvirality.com, with:

  • your App Key
  • The chosen mode of attribution: Only Referral Link or Only Referral Code

Keep the subject as: {{App_name}} Referral Attribution

where {{App_Name}} is your App’s name

To build a context, you may take a deeper dive into what each of these attribution settings implies

LINK + REFERRAL CODE (default)
ONLY REFERRAL LINK
ONLY REFERRAL CODE

 

Use Email ID of users to Initialize the SDK, everytime!

It is highly recommended that you use the User’s email ID for initializing the SDK every time. This will ensure that the user’s Referral Code & Invitation Link remains the same, regardless of the device he logs into.

 

Prefetching and populating the Referral Code from the invite received by the Friend, on his device during 1st App Launch

Welcome Screen
Welcome Screen

To elaborate this, when a new user acts on the Invite Link and installs the app – it is a convention nowadays to pre-fetch and populate the Referral Code of the Referrer in the Friend’s device during the onboarding, ideally during the Welcome Screen.

Unlike as shown in the image…

This can be done after the Integration is finished, in the following manner.

Instead of user entering his friend’s referral code manually, you can auto populate the same. So immediately on the 1st app launch of the app on the friend’s device, it is expected that you have initialized the SDK.

Follow up the initialization with calling out the getReferrerRefCode() method to get the Referrer’s Referral code. That should get you the code to populate on the Welcome Screen

ANDROIDiOS
  
  String referralCode = appVirality.getReferrerRefCode();

NOTE: If you are taking advantage of Google Install Referrer, you need not wait for AppVirality SDK Initialization, to get the Referral code. You can directly call the above method to populate the referral code during user signup

Referrer Code is available in Init callback.i.e. in referrerDetails.

  
  [AppVirality initWithApiKey:@"YOUR-APP-KEY" OnCompletion:^(NSDictionary *referrerDetails,NSError*error) {
            NSLog(@"User has Referrer %@", referrerDetails);
        }];

 

Once, as stated above, the Referral Code is entered, you would need to feed it back to AppVirality to close the loop on the attribution process. If not done, no rewards would be processed for the entire activity.

This will be most useful if the user is not attributed using Deep link(due to network changes/IP changes) or if user installs the App directly without clicking on referral link.

You need to use this method only if the attribution has not happened already using the Referral Link and user has to enter the referrer’s referral code to get attributed to him.

ANDROIDiOS
  
if (!appVirality.isAttributionConfirmed()) {
    appVirality.submitReferralCode(refCode, new AppVirality.SubmitReferralCodeListener() {
        @Override
        public void onResponse(boolean isSuccess, JSONObject responseData, String errorMsg) {
            String message = isSuccess ? "Referral Code applied Successfully" : (errorMsg != null ? errorMsg : "Failed to apply referral code");
            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
        }
    });
}

NOTE: If you have opted for Only Referral Code attribution setting, please make sure to execute the above method before sending any conversion events(i.e. Signup,Transaction..etc)

  
[AppVirality submitReferralCode:self.txtReferrerCode.text completion:^(BOOL success, NSError *error) {
            if (success) {
                NSLog(@"Referral Code applied Successfully");
                }
            else{
                NSLog(@"Invalid Referral Code");
            }

        }
        ];

 

AppVirality generates user referral code as soon as user requests for a campaign.

The referral code depends on the campaign that user interested to participate. Referral code is nothing but the campaign participation ID. This gets generated when AppVirality receives a request for campaign, from a user for the first time.

This is expected to be triggered when the User taps on the ‘Invite & Earn‘ button (or something likewise), from your app menu

We can get the referral code with the help of following code block

ANDROIDiOS
  
appVirality.getCampaigns(null, new AppVirality.CampaignDetailsListener() {
    @Override
    public void onGetCampaignDetails(ArrayList<CampaignDetail> campaignDetails, boolean refreshImages, String errorMsg) {
        CampaignDetail womCampaignDetail = appVirality.getCampaignDetail(Constants.GrowthHackType.Word_of_Mouth, campaignDetails);
        if (refreshImages) {
            // Refresh Word Of Mouth campaign images
        }
        if (womCampaignDetail != null) {
            String myReferralCode = womCampaignDetail.referralCode;
        }
    }
});
  
[AppVirality showGrowthHack:growthHack completion:^(NSDictionary *campaignDetails,NSError*error) {
NSString * myReferralCode = [campaignDetails valueForKey:@"shortcode"];
}];

 

Was this article helpful to you? Yes 10 No 2