我已经为我们的android应用程序实现了google分析活动跟踪。
请检查这个图像
在图像中,您可以看到新用户显示为零,会话显示计数,但不会在google分析控制台中更新任何新用户。
新用户不显示计数的原因是什么?
这是我的密码,请核对一下。
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false" />
<!--
Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
installation campaign reporting
-->
<receiver android:name="info.androidhive.googleanalyticsss.app.InstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
广播接收器接收器代码如下:
public class InstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.v("ReferralAction", " " + intent.getAction());
Log.v("ReferralString", " " + intent.getDataString());
Log.v("referral", " " + intent.toString());
Log.v("referral", " " + intent.getStringExtra("referrer"));
String rawReferrer = intent.getStringExtra("referrer");
String URL = "http://examplepetstore.com/index.html?" + rawReferrer;
MyApplication.getInstance().trackCampaigns(URL);
} catch (Exception e) {
System.out.print(e);
}
}
}
将活动URL发送到分析
t.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(url)
.build());
检查此URL:
活动网址:http://examplepetstore.com/index.html?utm_source=test_utmsource&utm_medium=test_utmmedium&utm_term=test_utmterm&utm_content=test_utmcontent&utm_campaign=test_utmname
最佳答案
在trackcampaigns上方添加此行
new CampaignTrackingReceiver().onReceive(context, intent);
在清单文件中添加接收器
<service
android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>