I got the same problem as in this question:
enableAutoActivityTracking not automatically tracking activities?
The problem is that the automated tracking does not work using Google Analytics.
However, calling enableAutoActivityReports
does not work in my case.
This is the configuration XML file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Google Analytucs property id. -->
<integer name="ga_sessionTimeout">300</integer>
<!-- catch and report uncaught exceptions from the app -->
<bool name="ga_reportUncaughtExceptions">true</bool>
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- The screen names that will appear in reports -->
<screenName name=".LoginActivity">
Login Activity
</screenName>
</resources>
In the application class:
private Tracker googleAnalyticsTracker;
public synchronized Tracker getGoogleAnalyticsTracker()
{
if (googleAnalyticsTracker == null)
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
analytics.enableAutoActivityReports(this);
googleAnalyticsTracker = analytics.newTracker(R.xml.global_tracker);
}
return googleAnalyticsTracker;
}
In the activity's onCreate
: ((MyApplication) getApplication()).getGoogleAnalyticsTracker();
However, in the same activity, if I put a manual screen view sending, I DO see it in the GA console. I do it like this:
Tracker t = ((MyApplication) getApplication()).getGoogleAnalyticsTracker();
t.setScreenName("Login Screen");
t.send(new HitBuilders.ScreenViewBuilder().build());