can anybody here explain how android app referral tracking works? a friend gave me an android app's google play referral url. And i installed the app and opened it. How does the app developer know that it's my friend who referred me to their app? I know that the link that my friend gave me contains his referral details but if i close google play after completing the app install, how can google play detect that i opened the app? So some unique data is injected into the app while i install it from playstore. am i right? Please explain.
It's quite simple actually. You click on the link with a referral (Google calls them Campaing Attribution) and this link is passed to the Google Play Store app. Then, when you install the app, the Play Store also forwards this data (campaign name, source, &c) to the app itself.
The app just needs to have a particular BroadcastReceiver
(with an intent-filter
for the com.android.vending.INSTALL_REFERRER
action) declared in its Manifest for this to work.
It's well explained in the Google Play Campaign Attribution section of the Google Analytics documentation.
Here is an example how you can implement a custom BroadcastReceiver with INSTALL_REFERRER.
AndroidManifest.xml
<receiver android:name=".CustomInstallTrackersReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
ManyInstallTrackersReceiver.java
import com.google.android.gms.tagmanager.InstallReferrerReceiver;
public class CustomInstallTrackersReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
// Implementing Google Referrer tracker
InstallReferrerReceiver googleReferrerTracking = new InstallReferrerReceiver();
googleReferrerTracking.onReceive(context, intent);
// Do something with referrer data to do your own tracker.
Log.d("CustomInstallTrackers", "Referrer: "+intent.getStringExtra("referrer"));
} catch(Exception e){
e.printStackTrace();
}
}
}
You can test it with the following commands
$ adb shell
$ am broadcast -a com.android.vending.INSTALL_REFERRER -n com.your.package/com.your.package.CustomInstallTrackersReceiver --es "referrer" "hello%3Dworld%26utm_source%3Dshell"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With