GoogleAnalyticsTracker.getInstance()是否需要跟踪推介?

时间:2010-08-10 00:22:59

标签: android google-analytics referrals

我正在尝试跟踪人们是否从广告或其他地方找到了我的Android应用。所以我发现谷歌分析可以通过这个表格生成的精心构建的URL来跟踪它:

http://code.google.com/mobile/analytics/docs/android/#android-market-tracking

看起来像这样:

http://market.android.com/search?q=pname:com.example.application&referrer=utm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3Dcampaign

...然后将分析.jar添加到我的项目中并将其添加到我的应用清单中:

<!-- Used for install referrer tracking -->
<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>

所以我的问题是:如果我想跟踪仅推荐而已,我是否需要任何GoogleAnalyticsTracker。*;我的活动中的代码?

1 个答案:

答案 0 :(得分:0)

不,您不需要使用GoogleAnalyticsTracker。

只需创建自己的Tracker类:​​

public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

    Bundle extras = intent.getExtras();
    String referrerString = extras.getString("referrer");

    Log.w("TEST", "### INSTALL_REFERRER EVENT: " + intent.getAction());     
    Log.w("TEST", "### REFFERER IS: " + referrerString);
}
}

并将下一行添加到AndroidManifest.xml

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

就是这样。