2
如何在不使用谷歌分析的情况下实施Google广告系列追踪系统?Google play campaign tracking without google analytics implementation android
我使用mixpanel跟踪目的
如何在不使用谷歌分析的情况下实施Google广告系列追踪系统?Google play campaign tracking without google analytics implementation android
我使用mixpanel跟踪目的
得到的答案,分享给别人参考
首先要创建一个广播接收器
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;
}
}
现在必须设置清单文件的接收器
<receiver
android:name=".ReferalIntentReciever"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
现在应用程序已准备好接收int安装后从Play商店发布的邮件
有没有办法打印/记录referrerString的值?还有,您可以给任何有关从应用发送回传的信息。谢谢 – onexf 2016-11-04 05:38:56