user2641233
user2641233

Reputation: 109

Campaign Measurement with own BroadcastReceiver

I've an Android app where user has to register. On sending registration, I want to send the parameters from the PlayStore (utm_source, etc.) to know from which campaign user comes from.

So the idea was to use a own BroadcastReceiver for INSTALL_REFERRER, where I save parameters to a file. When user registers i will read the file and send the content.

So I made receiver:

public class CampaignBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {


    String refferer = intent.getExtras().getString("referrer");
    try {
        FileOutputStream fos = context.openFileOutput("campaign", Context.MODE_PRIVATE);
        fos.write(refferer.getBytes());
        fos.close();
    } catch (FileNotFoundException e) {

    } catch (IOException e) {

    }


    new CampaignTrackingReceiver().onReceive(context, intent);
}

And, in AndroidManifest.xml I use :

<service android:name="com.google.analytics.tracking.android.CampaignTrackingService"/>
    <receiver android:name=".receiver.CampaignBroadcastReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

When i use the test scenario from google it works and the onReceive Method in my BroadcastReceiver is called.

./adb shell am  broadcast -a com.android.vending.INSTALL_REFERRER -n
mypackage/mypackage.receiver.CampaignBroadcastReceiver --es  "referrer" 
"utm_source%3Dtest%26utm_medium%3Dbanner%26utm_term%3Dmailstuff"

But, when I try it from PlayStore then nothing is called.

Has anybody idea how to grap the campaign parameters from the PlayStore in app?

Upvotes: 9

Views: 1440

Answers (1)

Benny
Benny

Reputation: 133

I don't know a workaround but the issue is known to Google.

Google Play Campaign Measurement does not currently support web-to-device installs initiated from the web Play Store.

Known Issues

Upvotes: 3

Related Questions