我想将广告系列数据发送到我的Google Analytics(GA)服务器
这是我的AndroidManifext.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.samples.quickstart.analytics">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:name=".AnalyticsApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Brian Start -->
<!-- Used for Google Play Store Campaign Measurement-->
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"
android:permission="android.permission.WAKE_LOCK"
android:enabled="true"
android:exported="true">
</service>
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
dispatching on non-Google Play devices -->
<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"/>
<!-- Brian End -->
</application>
</manifest>
我尝试通过命令行发送Broadcast,使用:
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n "com.google.samples.quickstart.analytics/com.google.android.gms.analytics.CampaignTrackingReceiver" --es referrer "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
我在命令行上得到了响应:
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.google.samples.quickstart.analytics/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) }
Broadcast completed: result=0
但是我在下面的logcat上得到了错误日志:
02-22 16:34:45.304 7134-7134/com.google.samples.quickstart.analytics W/GAv4: CampaignTrackingService service at risk of not starting. For more reliable installation campaign reports, add the WAKE_LOCK permission to your manifest. See http://goo.gl/8Rd3yj for instructions.
02-22 16:34:45.321 7134-7169/com.google.samples.quickstart.analytics W/GAv4: Ignoring duplicate install campaign
我尝试通过以下分区代码发送我的广告系列数据:
private void sendCampaignData() {
String name = getCurrentImageTitle();
switch(name) {
case "A":
{
Log.i(TAG, "Campaign Data A ----------------------");
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=email&utm_medium=email_marketing&utm_campaign=summerA" +
"&utm_content=email_variation_A";
Log.i(TAG, "Campaign Data: " + campaignData);
// Campaign data sent with this hit.
mTracker.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
break;
}
case "B":
{
Log.i(TAG, "Campaign Data B ----------------------");
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=cpc&utm_medium=cpc_video&utm_campaign=springB" +
"&utm_content=email_variation_B";
Log.i(TAG, "Campaign Data: " + campaignData);
// Campaign data sent with this hit.
mTracker.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
break;
}
case "C":
{
Log.i(TAG, "Campaign Data C ----------------------");
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=banner&utm_medium=banner_activity&utm_campaign=winterC" +
"&utm_content=email_variation_C";
Log.i(TAG, "Campaign Data: " + campaignData);
// Campaign data sent with this hit.
mTracker.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
break;
}
case "D":
{
Log.i(TAG, "Campaign Data D ----------------------");
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=google&utm_medium=google_link&utm_campaign=fallD" +
"&utm_content=email_variation_D";
Log.i(TAG, "Campaign Data: " + campaignData);
// Campaign data sent with this hit.
mTracker.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
break;
}
case "E":
{
Log.i(TAG, "Campaign Data E ----------------------");
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=google&utm_medium=google_link&utm_campaign=allE" +
"&utm_content=email_variation_E";
Log.i(TAG, "Campaign Data: " + campaignData);
// Campaign data sent with this hit.
mTracker.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
break;
}
default:
Log.i(TAG, "Campaign Data: Default");
}
但我在GA网站上看不到任何广告系列信息: https://www.google.com/analytics/web
它应该在 收购 - &gt;广告系列 - &gt;所有广告系列 但我的网站没有“广告系列”类别。
有谁知道发生了什么事?
感谢您的帮助。
BR 布赖恩
答案 0 :(得分:-1)
Ignoring duplicate install campaign
:此消息表示存在安装记录,您只需强制关闭应用并清除数据即可。