We have a mobile app that\'s available in both Google Play Store and Apple AppStore, we want to implement a referral program to get more users to install and use our App.
Android
On android you can create an install broadcast listener, where you can get and save the referrer part of the link to SharedPreferences
https://play.google.com/store/apps/details?id=com.example.app&referrer=example_referral_code_here
For this check
Android - Is it possible to get install referrer programmatically
and
Get referrer after installing app from Android Market
and
https://developer.android.com/google/play/installreferrer/library.html
iOS
For now (Jan 2016) It is not possible to get the install referrer code in your app, like with android.
Options i had for ios were:
An alternative is to let your current users make a unique code, for example, David123 or HenryABC. They share their code (which is easy to remember as it's personal). Within your app you provide a referral box that a new user enters the code to unlock additional features. This way you can track and don't have to worry about a fingerprint. The big issue with a fingerprint method is iOS is not unique enough and mobile networks share IP addresses. So someone with an iPhone 6s in London on EE is likely to have the same fingerprint as 100s of other people.
It can be done using Google Campaign Measurement where in the utm_source just give unique number/string for each user which you will receive when user's friend installs the app as Google Play store will broadcast it after the installation. Refer to this question.
Disclaimer: not being satisfied with the original accepted answer, I'm providing an alternative solution back to this "popular" thread.
On Android, this is not an issue at all. Google will let you access the referrer param sent at install time by registering a receiver, you can also leverage their install referrer API.
For iOS it is a bit trickier as it's not officially supported. As proposed here you can do fingerprinting but that's cumbersome and comes with a high degree of inaccuracy. There are two more elegant solutions I came across:
example.com/invite/123
), display a web page before redirecting to the App Store.UIPasteboard.general.string
(swift) and do some parsing or API callsGradle File
implementation 'com.android.installreferrer:installreferrer:1.0'
PUT CODE IN ACTIVITY WHERE IT NEED TO RECIEVE REFFERAL CODE
InstallReferrerClient mReferrerClient;
mReferrerClient = InstallReferrerClient.newBuilder(this).build();
mReferrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerClient.InstallReferrerResponse.OK:
// Connection established
try {
ReferrerDetails response =
mReferrerClient.getInstallReferrer();
if (!response.getInstallReferrer().contains("utm_source"))
edtPRferelCode.setText("" +
response.getInstallReferrer());
} catch (Exception e) {
e.printStackTrace();
}
mReferrerClient.endConnection();
break;
case
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
// API not available on the current Play Store app
break;
case
InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
// Connection could not be established
break;
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
SHARE LINK EXAMPLE
https://play.google.com/store/apps/details?id=com.yourpackage&referrer=9BE46300
We are doing a similar type of referral system in our app which provides certain amount of Reward Points to the referrer (one who actually shared the link to app) on successful install of the app by new user (one who received the link).
I will try to explain our implementation using your scenario: So according to your user story:
Every new user (E.g John) is given a unique referral link, which he/she can share it to his friends using FB/TW/Email or SMS.
When John's friend clicks on the link, he is re-directed first to a Servlet which eventually redirects him to respective AppStore based on his platform (Android/iPhone) to download the app.
Note that we can find out the IP address, user agent and device model of the user who clicked the link using a Servlet.
We already know that the referral link belongs to John and hence the servlet maps the IP address,user agent and/or device model of John's friend to John's entry in database.
The moment John's friend installs the app, and opens the app, the application sends the IP address, user agent and/or device model to the server.
The server checks the entry against all the user to find the referrer and if it finds him, in our case John, John gets rewarded accordingly..
Thats it. We implemented this in the last month itself and it does increased our downloads. Let me know if that's helpful.