You can use com.android.vending.INSTALL_REFERRER
.
The Google Play com.android.vending.INSTALL_REFERRER Intent is
broadcast when an app is installed from the Google Play Store.
Add this receiver to AndroidManifest.xml
<receiver
android:name="com.example.android.InstallReferrerReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Create a BroadcastReceiver:
public class InstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra("referrer");
//Use the referrer
}
}
You can test the referral tracking following the steps of this answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…