我在我的app中使用Google Analytics v4。我现在发布了我的应用程序我可以看到用户进行实时分析,但其他报告都是空的。这可能是什么原因造成的?我2天前开始使用分析仍然没有报告。但正如我所说,我可以在实时分析中看到用户。
这是我的追踪者:
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);
}
}
这是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>
我在onCreate()
方法中使用以下行:
Tracker t = ((Trackers) getApplication()).getTracker(Trackers.TrackerName.GLOBAL_TRACKER);
t.setScreenName("Main");
t.enableAdvertisingIdCollection(true);
t.send(new HitBuilders.AppViewBuilder().build());
这个用onResume()
方法:
GoogleAnalytics.getInstance(this).reportActivityStart(this);
答案 0 :(得分:0)
如果问题是为什么没有崩溃报告,而不是已知的错误,可能它与您的问题有关,更多here一般情况下,即使在V4中使用此行,也不会发送异常
<bool name="ga_reportUncaughtExceptions">true</bool>
编辑。也许更改为ScreenViewBuilder,因为AppViewBuilder已弃用。 https://developer.android.com/reference/com/google/android/gms/analytics/HitBuilders.AppViewBuilder.html