Google Analytics, Install Tracking android

断了今生、忘了曾经 提交于 2020-01-12 20:40:59

问题


I want track install referer for my application using google analytics.
I don't want use the Tracking Pageviews and Events feature, only install.
So I added the sdk jar in my app, add these lines to the manifest :

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

And publish the app.
But how can see the stats ? I never entered my UA-xxxxxxx id.

For the Pageviews and Events tracking it's here :

tracker.start("UA-YOUR-ACCOUNT-HERE", this);

But as thew readme says : (NOTE: do not start the GoogleAnalyticsTracker in your Application onCreate() method if using referral tracking).

But with referer where do I put my id ?
And what is the url to watch in the google analytics console ?

Thx


回答1:


This won't work. The receiver you declared in your manifest is defined in Analytics library, however all this receiver does is stuffs the event (e.g. the referrer info) into an google_analytics.db sqlite database inside your project's data dir.

Only after you call tracker.start() with the appropriate ID, the tracker is started, and later on when you do something like tracker.trackPageView("/main") the referrer info is passed on into Google Analytics servers... And of course the URL in this case is '/main'.

The "referrer" does not make sense on it's own, only in the context of the pageview.




回答2:


the way to do it is more or less like this :

@Override
public void onReceive(Context context, Intent intent) {
    Log.v("ReferralReceiver", " " + intent.getAction());
    Log.v("ReferralReceiver", " " + intent.getDataString());
    Log.v("ReferralReceiver", " " + intent.toString());
    Log.v("ReferralReceiver", " " + intent.getStringExtra("referrer"));

    Log.v("ReferralReceiver", "Starting the traker");
    super.onReceive(context, intent);

    GoogleAnalyticsTracker tracker = GoogleAnalyticsTracker.getInstance();
    tracker.start(UI_CODE, context);
    tracker.trackPageView("Referral");
    Log.v("ReferralReceiver", "Dispacthing and closing");
    tracker.dispatch();
    tracker.stop();
}

I explain a bit more how referral tracker work in this article : http://www.dev-articles.com/article/Analytics-referral-tracking-for-Android-447001



来源:https://stackoverflow.com/questions/4604039/google-analytics-install-tracking-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!