安装来源跟踪在Android网页市场上不起作用

8
当通过手机上的市场应用程序安装应用时,应用程序将正确地接收传递给它的引荐信息(如此处所述:http://code.google.com/mobile/analytics/docs/android/#android-market-tracking)。
然而,当通过基于Web的市场安装相同的应用程序并使用相同的引荐者时,引荐信息会被删除,应用程序无法接收到。这使得从Web针对您的应用程序进行的推广活动无法跟踪。
是否可能通过Android Web Market跟踪安装引荐者?
2个回答

6
不,无法从基于Web的Google Play商店跟踪安装引荐者。这是最新SDK的已知问题。
Google Play广告追踪目前不支持从Web Play商店启动的设备安装。

3
文档链接和“已知问题”部分是针对旧版本v2的。从较新的版本开始,“已知问题”部分已经被删除。那么,现在该功能是否可用?对我来说似乎不行,也就是说,“通过 Web 市场没有引荐者”的原始问题仍然存在。 - Juuso Ohtonen

0

可能有点晚了。幸运的是,这对我们来说可以跟踪从网络商店安装的应用程序。

接收器类:

public class OwnReceiver extends BroadcastReceiver {

public static final String ACTION_UPDATE_DATA = "ACTION_UPDATE_DATA";
private static final String ACTION_INSTALL_REFERRER = "com.android.vending.INSTALL_REFERRER";
private static final String KEY_REFERRER = "referrer";

public OwnReceiver() {
}

@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null) {
        Log.e("ReferrerReceiver", "Intent is null");
        return;
    }
    if (!ACTION_INSTALL_REFERRER.equals(intent.getAction())) {
        Log.e("ReferrerReceiver", "Wrong action! Expected: " + ACTION_INSTALL_REFERRER + " but was: " + intent.getAction());
        return;
    }
    Bundle extras = intent.getExtras();
    if (intent.getExtras() == null) {
        Log.e("ReferrerReceiver", "No data in intent");
        return;
    }

    MyApplication.setReferrerDate(context.getApplicationContext(), new Date().getTime());
    //Contro.setReferrerData(context.getApplicationContext(), (String) extras.get(KEY_REFERRER));
    MyApplication.setReferrerData(context.getApplicationContext(), (String) extras.get(KEY_REFERRER));
    LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ACTION_UPDATE_DATA));
}
}

在MainActivity中的使用:

private final BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
       someMethod(); //send received data to your method and use it your way
    }
};

在接收数据的someMethod方法中:

 private void someMethod(){
    String referrerDataRaw = MyApplication.getReferrerDataRaw(getApplicationContext());

    if(referrerDataRaw.toLowerCase().contains(matchx.toLowerCase())){        
        Log.i("true",referrerDataRaw);
        Toast.makeText(getBaseContext(),"Install referrer found",Toast.LENGTH_SHORT).show();
        //postBack();
    }
    else {
        Log.i("false","no referrer found");
        Toast.makeText(getBaseContext(),"no referrer found",Toast.LENGTH_SHORT).show();
    }

}

奖励 如果您正在发送回传,则可以使用此选项

public void postBack() {
   // String postTest = "https://play.google.com/store/apps/details?id=com.neon.myApp&referrer=utm_source=someOne&utm_medium=cpr&utm_term=testytest";
    String referrerDataRaw = MyApplication.getReferrerDataRaw(getApplicationContext());

   // Toast.makeText(this, "raw : " + postTest, Toast.LENGTH_SHORT).show();
    String[] split  = referrerDataRaw.split("=");
    String end = split[split.length - 1];

    Toast.makeText(this,  AppConstant.lin + end, Toast.LENGTH_SHORT).show();

    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConstant.lin + end, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            Toast.makeText(getBaseContext(),"postback sent",Toast.LENGTH_SHORT).show();

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {

        }
    });

    // Adding request to request queue
    MyApplication.getInstance().addToRequestQueue(strReq, tag_string_req);
}

得到了来自这位Github上的热心人士的大部分帮助 https://github.com/SimonMarquis/Android-InstallReferrer


请注意,这种方法将在2020年3月1日停止工作。对于新代码,请改用https://developer.android.com/google/play/installreferrer/library.html。 - Brian

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接