Android的转诊分析v3时被删除? [英] Android referral removed in analytics v3?

查看:280
本文介绍了Android的转诊分析v3时被删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了过去两天试图找到这一种变通方法。

I've spent the last two days trying to find a workaround for this.

我需要pre-Config中我的应用程序取决于转诊和谷歌,因为该剧播出已安装应用程序时的安装参照意图,我创建了自己的接收器完成这个任务。在code的舱单申报和接收器:

I need to pre-config my app depending on the referral and since google play is broadcasting an Install Referrer intent when an app is installed, I created my own receiver for this task. The code for the manifest declaration and the Receiver is:

舱单申报:

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

而CustomReceiver的简化code:

And the simplified code of the CustomReceiver:

public class CustomReceiver extends BroadcastReceiver {

private static final String CAMPAIGN_SOURCE_PARAM = "utm_source";

@Override
public void onReceive(Context context, Intent intent) {

    Log.d("debug", "waking receiver");
    Uri uri = intent.getData();
    getReferrerMapFromUri(uri);

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

void getReferrerMapFromUri(Uri uri) {

    MapBuilder paramMap = new MapBuilder();

    // If no URI, return an empty Map.
    if (uri == null) {
        Log.d("debug", "intent null");

        return;
    }

    if (uri.getQueryParameter(CAMPAIGN_SOURCE_PARAM) != null) {

        // MapBuilder.setCampaignParamsFromUrl parses Google Analytics
        // campaign
        // ("UTM") parameters from a string URL into a Map that can be set
        // on
        // the Tracker.
        paramMap.setCampaignParamsFromUrl(uri.toString());

        Log.d("debug", paramMap.get(Fields.CAMPAIGN_SOURCE));

        // If no source parameter, set authority to source and medium to
        // "referral".
    } else if (uri.getAuthority() != null) {

        paramMap.set(Fields.CAMPAIGN_MEDIUM, "referral");
        paramMap.set(Fields.CAMPAIGN_SOURCE, uri.getAuthority());

    }
}

}

这就是全部。我发送广播安装意向与ADB命令,但它没有得到根本激活。我使用谷歌分析V3。

That's all. I am sending broadcast install intent with the adb shell command but it's not getting activated at all. I am using google analytics v3.

感谢你在前进!

推荐答案

我试过这种方式。和它的工作。(我也使用谷歌分析V3)

I've tried this way. And it does work.( I am also using Google Analytics v3)

首先,在清单:

<!-- Used for Google Play Store Campaign Measurement-->;
<service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />
<receiver android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver" android:exported="true" >
   <intent-filter>
       <action android:name="com.android.vending.INSTALL_REFERRER" />
   </intent-filter>
</receiver>

二,添加一个CustomReceiver延伸广播接收器
(在我而言,我只是复制和粘贴的所有codeS开发商)

Second, add an CustomReceiver extends BroadcastReceiver ( In my case, I just copy and paste all the codes from developers )

package com.example.testanalytics;

import com.google.analytics.tracking.android.CampaignTrackingReceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class CustomReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
    // Pass the intent to other receivers.

    // When you're done, pass the intent to the Google Analytics receiver.
    new CampaignTrackingReceiver().onReceive(context, intent);
}
}

最后一步:在我的活动(我想将消息发送给谷歌分析)
创建一个意图,并调用sendBroadcast(意向)如下:

last step: in my activity( which I want to send messages to Google Analytics ) create an Intent and call sendBroadcast( Intent ) as follow:

Intent it = new Intent("com.android.vending.INSTALL_REFERRER");

it.setPackage("com.example.testanalytics");
it.putExtra("referrer", "utm_source%3Dyahoo%26utm_medium%3Dbanner+cpc%26utm_term%3Debook%26utm_content%3Dmy_content%26utm_campaign%3Dmy_campaign_name_2");

sendBroadcast(it);

和刚刚得到它。
我希望这可以帮助你。

And just get it. I hope this may help you.

这篇关于Android的转诊分析v3时被删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆