Android 推荐跟踪不起作用

发布于 2024-10-11 18:51:25 字数 2725 浏览 1 评论 0原文

我正在尝试让 Android 推荐跟踪正常工作。我正在遵循我在这里找到的唯一文档 http://code.google.com/mobile/analytics /docs/android/#referrals 我的 android 清单文件 com.package.Receiver 开头有以下内容

<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"/>  

public void onReceive(Context paramContext, Intent paramIntent) {  
        String str1 = paramIntent.getStringExtra("referrer");  
        Log.i("myapp", "action: '" + paramIntent.getAction() + "'  
referrer string: '" + str1 + "'"); 

另外,还进行了一些反编译 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");  
/*     */     }  
/*     */   }  

请注意记录“googleanalytics”的第 36 行和第 38 行,我曾尝试将上述应用程序推向市场,将其下载到我的 Nexus One 上(在卸载该应用程序的先前版本之后)。我已经使用本文开头链接到的谷歌页面生成了一个链接

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=AFQj CNFctwqk1WgWl0bhiIBNVqy3U4OPRw

我将 logcat 连接到我的 Nexus One,同时我从该链接下载该应用程序,但没有看到来自“googleanalytics”或“myapp”的任何日志。谷歌分析库的其余部分确实适用于我的应用程序。 IE 我在谷歌分析上看到有关页面点击率等的记录。但是所有流量来源都是“直接流量”。我不知道发生了什么。有没有人 对我可能做错了什么有任何见解吗?

I am attempting to get Android Referral tracking to work. I am following the only documentation I have found here http://code.google.com/mobile/analytics/docs/android/#referrals I have the following in my android manifest file

<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"/>  

com.package.Receiver starts with:

public void onReceive(Context paramContext, Intent paramIntent) {  
        String str1 = paramIntent.getStringExtra("referrer");  
        Log.i("myapp", "action: '" + paramIntent.getAction() + "'  
referrer string: '" + str1 + "'"); 

Also with a little bit of decompiling com.google.android.apps.analytics.AnalyticsReceiver has the following code in it:

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");  
/*     */     }  
/*     */   }  

Note the two lines 36 and 38 that Log "googleanalytics" I have tried pushing the above app to the market, downloading it on my Nexus One (after uninstalling a previous version of the app). I have generated a link using the google page I linked to at the beginning of this post

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

I attached logcat to my Nexus One while I download the app from that link, I do not see any logs from "googleanalytics" or "myapp". The rest of the google analytics library does work for my app. I.E. I see records on google analytics about pages hits etc. However all the traffic sources are "Direct Traffic". I am at a loss as to what is going on. Does anyone
have any insight into what I might be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风透绣罗衣 2024-10-18 18:51:25

正如通常的情况一样,我找到了自己的答案。我的问题出在我的 AndroidManifest.xml 中,

我的清单中有以下内容:

<manifest>
    <application>
    </application>
    <receiver>
    </receiver>
    <uses-sd/>
 </manifest>    

接收器标签位于错误的位置。它应该看起来像这样

<manifest>
    <application>
        <receiver>
        </receiver>
    </application>
    <uses-sd/>
 </manifest>  

,我现在看到了安装应用程序时所期望的日志。几个小时后,希望 Google Analytics 也能获得这些数据。

As is often the case I found my own answer. My problem was in my AndroidManifest.xml

I had the following in my manifest:

<manifest>
    <application>
    </application>
    <receiver>
    </receiver>
    <uses-sd/>
 </manifest>    

The receiver tag was in the wrong spot. It should look like this

<manifest>
    <application>
        <receiver>
        </receiver>
    </application>
    <uses-sd/>
 </manifest>  

I am now seeing the logs I expect to when I install the app. In a few hours hopefully Google Analytics will have the data as well.

枯叶蝶 2024-10-18 18:51:25

我已经探索了很多带有 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);

I have explore quite a lot the referral tracker with analytics for android. You don't need to put the app in the market you can just send a broadcast intent.

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);
彩虹直至黑白 2024-10-18 18:51:25

一项操作只能有一个广播接收器。在 AndroidManifest.xml 中,您有两个监听 com.android.vending.INSTALL_REFERRER 的内容。

如果您希望您的接收器和 Google Analytics 接收器都处理该意图,请使您的接收器成为 AnalyticsReceiver 的子类,如下所示:

import com.google.android.apps.analytics.AnalyticsReceiver;

class Receiver extends AnalyticsReceiver {
    @Override
    void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);

        // Add your custom handling here
    }
}

然后确保您的接收器是 AndroidManifest.xml 中唯一的接收器:

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

There can be only one BroadcastReceiver for an action. In your AndroidManifest.xml, you have two listening for com.android.vending.INSTALL_REFERRER.

If you want to your receiver AND the Google Analytics receiver to both handle the intent, make your receiver a subclass of AnalyticsReceiver, like this:

import com.google.android.apps.analytics.AnalyticsReceiver;

class Receiver extends AnalyticsReceiver {
    @Override
    void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);

        // Add your custom handling here
    }
}

Then make sure yours is the only receiver in AndroidManifest.xml:

<receiver android:name="com.package.Receiver" android:exported="true">
  <intent-filter>
    <action android:name="com.android.vending.INSTALL_REFERRER" />
  </intent-filter>
</receiver>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文