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
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 .
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With