kri*_*amn 7 android google-analytics android-intent android-service google-analytics-firebase
我开始使用Google Analytics V4实施广告系列衡量,参考链接 https://developers.google.com/analytics/devguides/collection/android/v4/.遇到https://developers.google.com/analytics/solutions/testing-play-campaigns中提到的经过测试的Campign Measurement时遇到的问题.每次我的日志显示"未找到广告系列数据"
我将google Play服务(版本:18)导入我的工作区并在我的项目中引用它
在我的清单文件中添加了以下行
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/global_tracker" />
Run Code Online (Sandbox Code Playgroud)
以及代码下面
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
后来在res-> xml下创建了global_tracker.xml文件.下面是我的xml文件
<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="TypographyDashes"
>
<integer name="ga_sessionTimeout">300</integer>
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_debug">true</bool>
<string name="ga_logLevel">verbose</string>
<string name="ga_dryrun">true</string>
<!-- The screen names that will appear in reports -->
<!-- The following value should be replaced with correct property id. -->
<string name="ga_trackingId">UA-xxxxxxx-1</string>
</resources>
Run Code Online (Sandbox Code Playgroud)
已使用我的跟踪ID替换了跟踪ID
在测试广告系列衡量时,我首先通过adb install将我的应用安装到我的设备上(Moto G(4.4.2)).确保应用程序未运行并广播上述链接中提到的意图.我在广播意图时获得了成功记录.
意图
E:\xxxxxxx\adt-bundle-windows-x86_64-20140321\sdk\platform-tools
>adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <My Package name>/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testsource"
Run Code Online (Sandbox Code Playgroud)
响应:
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=<My Package name>
>/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) }
Broadcast completed: result=0
Run Code Online (Sandbox Code Playgroud)
当我打开我的应用程序时,我总是得到" I/GAV2(7342):线程[GAThread,5,main]:找不到广告系列数据. "我的日志中出错.
可以请有人告诉我为什么我没有获得广告系列数据?我哪里错了.
此外,当我使用GAV4时,为什么它在日志中显示"GAV2"
GA日志:
07-09 12:59:26.542: W/GAV2(20502): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
07-09 12:59:31.568: I/GAV2(20502): Thread[GAThread,5,main]: No campaign data found.
Run Code Online (Sandbox Code Playgroud)
注意:这是我第一次使用Google Analytics.由于我想先检查我是否收到广告系列数据,因此我没有对GA实施任何跟踪器
编辑:当我手动触发广播意图按钮时,单击我的应用程序.当我重新启动我的应用程序时,我能够看到"Campaign found"日志.但是,如上所述,使用"adb shell"命令触发意图时也不会发生同样的情况.我怀疑可能是意图没有达到我的设备.有没有办法找到是否收到意图?
请帮忙
1>对于初学者你可以混合两件事.此链接适用于Google Analytics-v4 https://developers.google.com/analytics/devguides/collection/android/v4/ ,此链接https://developers.google.com/analytics/solutions/testing-play-campaigns不适用于v4(页面太旧,此页面发布时没有GAV4.
2>检查物理设备(Google Play服务)版本并将其更新为5.0(如果尚未完成).
3>你不需要下面提到的锅炉板代码.我认为这是针对GAV3而不是GAV4
<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
为了更清晰的代码检查此链接.未找到广告系列数据.使用Google Analytics v4
4>专门针对GAV4(凭借我自己的经验),可以看到错误"找不到广告系列数据".尝试以详细模式运行代码,您将看到GAV4正在与其主机建立连接.
GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE);
Run Code Online (Sandbox Code Playgroud)
5>不要打开dry_run,您将无法在Google Analytics上看到数据.默认情况下,这是关闭的.
6>最后,Google Analytics内部会在"实时"下查看实时点击.
希望这可以帮助.
归档时间: |
|
查看次数: |
6865 次 |
最近记录: |