I am using my custom broadcast receiver as follows to track UTM parameters.
<receiver
android:name=".services.CustomInstallListener"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
public class CustomInstallListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.hasExtra("referrer")) {
String data = intent.getStringExtra("referrer");
String referrers[] = data.split("&");
for (String referrerValue : referrers) {
String keyValue[] = referrerValue.split("=");
if (keyValue.length > 0) {
if (keyValue[0].equalsIgnoreCase("utm_campaign")) {
... something
}
}
}
}
I have also implemented the InstallReferralClient as follows
referrerClient.startConnection(new InstallReferrerStateListener() {
@Override
public void onInstallReferrerSetupFinished(int responseCode) {
switch (responseCode) {
case InstallReferrerClient.InstallReferrerResponse.OK:
ReferrerDetails response = null;
try {
response = referrerClient.getInstallReferrer();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
@Override
public void onInstallReferrerServiceDisconnected() {
}
});
And I used the Google Play Url Builder to generate this URL.
Now I have it tried with both HTTP and https URLs and tried some other solutions following some other questions on StackOverflow but nothing seems to work.
For all the UTM parameters passed in the URL to play store, I am getting (not%20set) as value. I have also tried using the URL in the deep link from the branch and firebase dynamic links and I am getting the same error.
But I am sure that the code to handle this is correct as it returns campaign and medium value as Google and organic respectively when directly installing from Play Store.