I'm trying to connect google Analytics to my apps in the simplest way possible. I want to implement analytics v4, because google said that they'll force to upgrade to it soon, so I don't want to do twice the same work.
Google's tutorial, in this case, is not very efficient. Merging what they said there and what I've found on the internet, I've made this steps:
In Android Manifest, I've add this permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
and this, under the Application tag:
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
android:resource="@xml/analytics" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
I'm not sure of the necessity of the second meta...
I've wrote an xml file, named "analytics.xml" (/res/xml/) containing:
<!-- the Local LogLevel for Analytics -->
<string name="ga_logLevel">verbose</string>
<!-- Treat events as test events and don't send to google -->
<bool name="ga_dryRun">false</bool>
<!-- <integer name="ga_sessionTimeout">300</integer> -->
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<!-- Enable automatic exception tracking -->
<bool name="ga_reportUncaughtExceptions">true</bool>
<string name="ga_trackingId">UA-52900555-1</string>
<!-- The screen names that will appear in reports -->
<screenName name="com.maik.adbconnect.EmpityActivity">
Adb Activation
</screenName>
<screenName name="com.maik.adbconnect.wid_class">
Widget call
</screenName>
Now, in EmpityActivity.java, I've wrote this, at beginning of onCreate method:
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker(R.xml.analytics);
t.send(new HitBuilders.AppViewBuilder().build());
In LogCat, analytics says that is started and hits... but in my analytics review, under "real time users", says zero....
Additional questions:
screennames in xml file are needed?
ga_logLevel and ga_dryRun are deprecated? Because logcat warn me that those resources are not recognized