Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics, Install Tracking android

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

like image 592
vieux Avatar asked Jan 05 '11 12:01

vieux


People also ask

How do I install Google Analytics on Android?

Get the project If this is your first time using a Google services sample, check out the google-services repository. Open Android Studio. Select File > Open, browse to where you cloned the google-services repository, and open google-services/android/analytics .

How do I install Google tracking?

Go to google.com/analytics. To create an account, click Get started today. If you already have a Google Analytics account, click Sign in to Analytics. Set up Analytics on your website and/or app.


2 Answers

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

like image 66
Luigi Agosti Avatar answered Sep 28 '22 08:09

Luigi Agosti


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.

like image 40
haimg Avatar answered Sep 28 '22 08:09

haimg