您可以實現自己的接收器,從INSTALL_REFERRER
意圖中獲得referral
字符串,做一些工作,然後將意圖傳遞給Google Analytics接收器。
下面是一個例子:
package com.example.app;
import com.google.analytics.tracking.android.CampaignTrackingReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class NotePadReceiver extends BroadcastReceiver {
// The name of the referrer string broadcast by Google Play Store.
private static final String PLAY_STORE_REFERRER_KEY = "referrer";
@Override
public void onReceive(Context context, Intent intent) {
String referrer = intent.getStringExtra(PLAY_STORE_REFERRER_KEY);
// Do something with the referrer.
// When you're done, pass the intent to the Google Analytics Campaign Tracking Receiver.
new CampaignTrackingReceiver().onReceive(context, intent);
}
}
好涼爽,所以我在我的包中添加一個新的文件,我試圖登錄引薦'Log.e(「--------- REFERRER ----------「,referrer);'但沒有在日誌中顯示。我的項目應該在哪裏? – hanleyhansen
這是我能夠在本地測試的東西,還是隻能與已發佈的應用程序一起使用? – hanleyhansen
下面是一段看起來相關的跟蹤:[trace](https://gist.github.com/hanleyhansen/5042b0506de4ee0a7e58) – hanleyhansen