1

I'm trying to track whether people have found my Android app from an ad, or elsewhere. So I found that google analytics can keep track of that via the carefully constructed url generated by this form:

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

which would look something like this:

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

...and then adding the analytics .jar to my project and adding this to my app's manifest:

<!-- 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>

So my question is: if I want to track only referrals and nothing more, do I need any of the GoogleAnalyticsTracker.*; code in my activities?

4

1 回答 1

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>

而已。

于 2011-05-03T06:30:11.750 回答