I am using Google Analytics v4 in my app.I published my app now I can see users in real time analytics but other reports are empty.What can be cause this ? I started using analytics 2 days ago still there is no report.But as I said I can see users in real time analyics.
This is my tracker:
package com.impact.ribony;
import java.util.HashMap;
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
public class Trackers extends Application
{
public enum TrackerName
{
APP_TRACKER, // Tracker used only in this
// app.
GLOBAL_TRACKER, // Tracker used by all the
// apps from a company.
// eg: roll-up tracking.
ECOMMERCE_TRACKER, // Tracker used by all
// ecommerce
// transactions from a
// company.
}
HashMap<TrackerName, Tracker> mTrackers = new HashMap<TrackerName, Tracker>();
public synchronized Tracker getTracker(TrackerName trackerId)
{
if (!mTrackers.containsKey(trackerId))
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
if( trackerId == TrackerName.GLOBAL_TRACKER )
{
mTrackers.put(trackerId, analytics.newTracker(R.xml.global_tracker));
}
}
return mTrackers.get(trackerId);
}
}
This is global_tracker.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:ignore="TypographyDashes">
<!-- Enable automatic Activity measurement -->
<bool name="ga_autoActivityTracking">true</bool>
<bool name="ga_reportUncaughtExceptions">true</bool>
<!-- The screen names that will appear in reports -->
<screenName name="com.impact.ribony.MainActivity">MainActivity</screenName>
<!-- The following value should be replaced with correct property id. -->
<string name="ga_trackingId">UA-42075172-2</string>
</resources>
And I am using following lines in onCreate()
method:
Tracker t = ((Trackers) getApplication()).getTracker(Trackers.TrackerName.GLOBAL_TRACKER);
t.setScreenName("Main");
t.enableAdvertisingIdCollection(true);
t.send(new HitBuilders.AppViewBuilder().build());
And this one in onResume()
method:
GoogleAnalytics.getInstance(this).reportActivityStart(this);
If the question is about why there is no crash reports, than it is a known bug, maybe it is someway linked with your problem, more here In general exceptions are not dispatched even with this line in V4-
<bool name="ga_reportUncaughtExceptions">true</bool>
Edit. Maybe change to ScreenViewBuilder, because AppViewBuilder is deprecated. https://developer.android.com/reference/com/google/android/gms/analytics/HitBuilders.AppViewBuilder.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.