Retrieving the Install Referrer URL from my Android App Context

Introduction

To retrieve the Install Referrer from your Android App Context, you must add an additional receiver at your AndroidManifest.xml. The receiver is called upon every time an app install is either generated from AppsFlyer's tracking links or has a referrer parameter.

Adding the Receiver

Android apps cannot have multiple receivers that have the same intent-filtered action. However, AppsFlyer provides a solution that broadcasts INSTALL_REFERRER to all other receivers automatically.

In the AndroidManifest.xml, add the following receiver as the FIRST for INSTALL_REFERRER, and your other receivers just below it:

 Note

AppsFlyer Install Receiver is first and broadcasts to all receivers placed below it.

<receiver android:name="com.appsflyer.MultipleInstallBroadcastReceiver" android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>
<!—All Other receivers should follow right after -->    
<receiver android:name="MyReceiver" android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>


Your new receiver (MyReceiver) is called upon every time an install is either generated from AppsFlyer's tracking links or has a referrer parameter.

 Example

AF tracking link used to install the app:

app.appsflyer.com/angry-birds-android?pid=tapjoy_int&clickid=1020fe4c7e875&c=
Ad1&af_siteid=2684

Referrer Received

af_tranid=3M69WKEKDHFPRXPG&pid=tapjoy_int&clickid=1020fe4c7e875&c=Ad1&af_siteid=2684

af_tranid is an AppsFlyer internal transaction ID. All the rest of the parameters are taken directly from the installation URL query string.

Integration Test

Follow the normal test procedure here. The expected referrer string is: AppsFlyer_TEST

Was this article helpful?
3 out of 3 found this helpful