Reputation: 28519
From Application onCreate(), to test event/screen logging:
public static void logUserAction(String eventName) {
Timber.i("Logging to Google Analytics");
Tracker t = getTracker();
t.setScreenName(eventName);
t.send(new HitBuilders.ScreenViewBuilder().build());
t.send(new HitBuilders.EventBuilder()
.setCategory("Event")
.setAction(eventName)
.setLabel(eventName)
.setValue(1)
.build());
}
synchronized static Tracker getTracker() {
if (googleAnalyticsTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(application);
googleAnalyticsTracker = analytics.newTracker(R.xml.global_tracker);
}
return googleAnalyticsTracker;
}
Config file, global_tracker.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="ga_sessionTimeout">300</integer>
<string name="ga_trackingId">UA-ACTUAL_VALUE_USED_HERE</string>
</resources>
Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Build file
compile 'com.google.android.gms:play-services-analytics:7.0.0'
The UA tracking code I'm using is definitely correct. The project builds and executes, however although the log message is shown to confirm the code is called, absolutely nothing happens in debug or release builds. No data is showing in Analytics, and there is nothing in Logcat to guide me.
What did I miss?
Upvotes: 0
Views: 380
Reputation: 8386
Like my comment said, you have to wait some times after the "Google Analytics ID" creation, before you can view any reports.
Upvotes: 1