Note: The broadcast referral functionality has been deprecated by Google Play and will be removed on March 2020. The new implementation involves connecting directly to the Play Store app - documentation is available at https://developer.android.com/google/play/installreferrer
The install referrer is an intent on android, which is broadcast after the app install to give the app information about the reason it was installed. This is useful if you're tracking marketing / paid installs and you want to tell between paid and organic installs.
But testing this can be a huge pita, as you need to have your manifest setup to correctly add a listener for this intent, and you need to time the broadcast correctly.
Due to how android applications are designed, there may be several components active at any point in time. If you have a reciever correctly configured for the INSTALL_REFERRER
intent - i.e. you have the following section in your AndroidManifest
<receiver android:name="CLASSPATH TO YOUR RECEIVER" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Then as soon as your application is on the system (after install) the component above will be invoked when an intent with the above action is sent.
To test this you can run
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <packagename>/.<java classname> --es "referrer" "referrer=value&stuff=url"
After the app has been installed (but before it is launched). The timing between install and launch isn't as important - the information will be there on the first launch of the application.