pat*_*ros 11 android google-analytics referrer
我正在尝试让Android推荐跟踪工作.我正在关注我在此处找到的唯一文档http://code.google.com/mobile/analytics/docs/android/#referrals 我在我的android清单文件中有以下内容
<receiver
android:name="com.google.android.apps.analytics.AnalyticsReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<receiver android:name="com.package.Receiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<uses-sdk android:minSdkVersion="4"/>
Run Code Online (Sandbox Code Playgroud)
com.package.Receiver以:
public void onReceive(Context paramContext, Intent paramIntent) {
String str1 = paramIntent.getStringExtra("referrer");
Log.i("myapp", "action: '" + paramIntent.getAction() + "'
referrer string: '" + str1 + "'");
Run Code Online (Sandbox Code Playgroud)
还有一点反编译com.google.android.apps.analytics.AnalyticsReceiver中包含以下代码:
public void onReceive(Context ctx, Intent intent)
/* */ {
/* 24 */ String referrer = intent.getStringExtra("referrer");
/* */
/* 26 */ if ((!
("com.android.vending.INSTALL_REFERRER".equals(intent.getAction())))
|| (referrer == null))
/* */ {
/* 28 */ return;
/* */ }
/* */
/* 31 */ String formattedReferrer = formatReferrer(referrer);
/* */
/* 33 */ if (formattedReferrer != null) {
/* 34 */ PersistentEventStore store = new
PersistentEventStore(ctx);
/* 35 */ store.setReferrer(formattedReferrer);
/* 36 */ Log.d("googleanalytics", new
StringBuilder().append("Stored
referrer:").append(formattedReferrer).toString());
/* */ } else {
/* 38 */ Log.w("googleanalytics", "Badly formatted referrer, ignored");
/* */ }
/* */ }
Run Code Online (Sandbox Code Playgroud)
请注意记录"googleanalytics"的两行36和38我尝试将上述应用程序推向市场,在我的Nexus One上下载(卸载以前版本的应用程序后).我使用我在本文开头链接到的Google页面生成了一个链接
http://www.google.com/url?sa=D&q=http://market.android.com/search%3Fq%3Dpname:com.package.app%26referrer%3Dutm_source%253Dgoogle%2526utm_medium%253Dcpc%2526utm_term%253Drunning%25252Bshoes%2526utm_content%253Dcontent1%2526utm_campaign%253Dslogan&usg=AFQjCNFctwqk1WgWl0bhiIBNVqy3U4OPRw
当我从该链接下载应用程序时,我将logcat附加到我的Nexus One,我没有看到来自"googleanalytics"或"myapp"的任何日志.谷歌分析库的其余部分适用于我的应用程序.IE我在谷歌分析中看到关于页面点击等的记录.但是所有流量来源都是"直接流量".我不知道发生了什么.有没有人知道我可能做错了什么?
pat*_*ros 11
通常情况下,我找到了自己的答案.我的问题出在我的AndroidManifest.xml中
我的清单中有以下内容:
<manifest>
<application>
</application>
<receiver>
</receiver>
<uses-sd/>
</manifest>
Run Code Online (Sandbox Code Playgroud)
接收器标签位于错误的位置.它看起来应该是这样的
<manifest>
<application>
<receiver>
</receiver>
</application>
<uses-sd/>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我现在看到我在安装应用程序时所期望的日志.几个小时之内,Google Analytics也会提供数据.
我已经探索了很多关于android的分析跟踪器.您无需将应用程序置于市场中即可发送广播意图.
Intent i = new Intent("com.android.vending.INSTALL_REFERRER");
i.setPackage(com.package.yourapp)
//referrer is a composition of the parameter of the campaing
i.putExtra("referrer", referrer);
sendBroadcast(i);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9701 次 |
最近记录: |