How to Test Android Referral Tracking

How to test android referral tracking?

The easiest way is using adb. You don't have to write any code.

Just run in a terminal:

adb shell 
am broadcast -a com.android.vending.INSTALL_REFERRER -n <your.package>/.<path.up.until.your.BroadcastReceiver> --es "referrer" "utm_source=test_source\&utm_medium=test_medium\&utm_term=test_term\&utm_content=test_content\&utm_campaign=test_name"

Here's my exact line:

am broadcast -a com.android.vending.INSTALL_REFERRER -n net.lp.collectionista/.util.broadcast_receivers.FacadeBroadcastReceiver --es "referrer" "utm_source=test_source\&utm_medium=test_medium\&utm_term=test_term\&utm_content=test_content\&utm_campaign=test_name"

But your BroadcastReceiver may need to be the AnalyticsReceiver, i.e.

For Google Analytics v2:

com.your.package/com.google.analytics.tracking.android.CampaignTrackingReceiver

For Google Analytics v3:

com.your.package/com.google.android.apps.analytics.AnalyticsReceiver

For Google Analytics v4:

com.your.package/com.google.android.gms.analytics.CampaignTrackingReceiver

As Luigi said, you can also leave out the "-n" componentname part, but then every app on your device will receive the referral. This can be a good extra test to see if your BroadcastReceiver can be found properly.

The output I see (especially the last line is important):

05-13 17:28:08.335: D/Collectionista FacadeBroadcastReceiver(8525): Receiver called
05-13 17:28:08.335: V/Collectionista FacadeBroadcastReceiver(8525): Receiver called with action: com.android.vending.INSTALL_REFERRER
05-13 17:28:08.365: D/GoogleAnalyticsTracker(8525): Stored referrer:utmcsr=test_source|utmccn=test_name|utmcmd=test_medium|utmctr=test_term|utmcct=test_content

Android Install referral tracking uniqueness

  1. Yes the play store will send the referrer every time the app is installed using a link that contains parameters.

  2. If you care about uniqueness, you need some backend to verify that yourself. This is how e.g adjust does it. The referrer is stored in the Receiver and sent to a backend at some point in the future.

If you think of it it makes a lot of sense: The only thing that the Play Store App does is taking the referrer parameters from the url and delegating it back to the installed app. There is basically no logic involved here.

Also, the developers at google don't know whether you are interested in the uniqueness or not, so they will not prevent you from counting installs multiple times, if you want. (AFAIK the statistics panel in the Play Developer Console does filter out duplicates, but they're still delivered to your app)

How to test google play referrer api before publishing in Google play store?

Update

Beta test only works for referrer broadcast. I implement both installreferrer API and broadcast at the same time, so the referrer is from broadcast instead of API.


Use Beta test provided by Google Play as following:

  1. Submit beta test APK file
  2. Add your account to the testers
  3. Open the detail page url of your APP with a referrer. The url can be like this according to a similar thread:

    https://play.google.com/store/apps/details?id=com.mypackage&referrer=utm_source%3Dmobisoc%26utm_content%3D{transaction_id}%26utm_campaign%3D1

  4. If using Chrome, the url can be redirected to Play APP by clicking "Open in Play Market APP" button on the page.
  5. Download and install your APP in Play APP.

Your app should then receive a referrer after launch, and you can test it by reporting it or printing a log.

Alpha test should also work, but I have not test that.

Android referral tracking does not work

As is often the case I found my own answer. My problem was in my AndroidManifest.xml

I had the following in my manifest:

<manifest>
<application>
</application>
<receiver>
</receiver>
<uses-sd/>
</manifest>

The receiver tag was in the wrong spot. It should look like this

<manifest>
<application>
<receiver>
</receiver>
</application>
<uses-sd/>
</manifest>

I am now seeing the logs I expect to when I install the app. In a few hours hopefully Google Analytics will have the data as well.

How to use mixpanel analytics for referral tracking in android

First u have to write a broadcast receiver for receiving the referral intent

public class ReferalIntentReciever extends BroadcastReceiver {
public static MixpanelAPI mixpanel;

Context context;

@Override
public void onReceive(Context context, Intent intent) {
mixpanel = MixpanelAPI.getInstance(context, "YOUR MIXPANEL TOKEN");

// TODO Auto-generated method stub

String referrerString = intent.getStringExtra("referrer");
//sending to mixpanel
try {
JSONObject props = new JSONObject();
props.put("utm_source", splitQuery(referrerString)
.get("utm_source"));
props.put("utm_medium", splitQuery(referrerString)
.get("utm_medium"));
if (splitQuery(referrerString).get("utm_campaign") != null) {
props.put("utm_campaign",
splitQuery(referrerString).get("utm_campaign"));
}
mixpanel.track("Referral Campaign", props);
mixpanel.flush();

} catch (Exception e) {
e.printStackTrace();
}

}

//getting each parameter

public static Map<String, String> splitQuery(String url)
throws UnsupportedEncodingException {
Map<String, String> query_pairs = new LinkedHashMap<String, String>();
String[] pairs = url.split("&");
for (String pair : pairs) {
int idx = pair.indexOf("=");
query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"),
URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
}
return query_pairs;
}
}

and set the receiver in the manifest

<receiver
android:name=".ReferalIntentReciever"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

also check this
Google play campaign tracking without google analytics implementation android



Related Topics



Leave a reply



Submit