没有获得谷歌分析的读数 - Android

时间:2017-09-27 09:56:00

标签: java android google-analytics

我有4个fragments和2 activities我已经实现了以下代码:

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;

//...
private Tracker mTracker;
//...
AnalyticsApplication application = (AnalyticsApplication) getActivity().getApplication();
    mTracker = application.getDefaultTracker();
//...
@Override
public void onResume() {
    Log.i(TAG, ""+TAG); //TAG represents the name of the current activity/fragment     
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    super.onResume();
}

我想要做的是跟踪每个活动和片段的使用情况,并实时获取当前活跃用户并在我的Google Analytics控制台中接收信息,但我没有设法接收任何数据

P.S。到目前为止,我只测试了我的设备

1 个答案:

答案 0 :(得分:0)

通过添加以下行来实现:

mTracker.setScreenName("Screen name: " + TAG);

最终结果

@Override
public void onResume() {
    Log.i(TAG, ""+TAG); //TAG represents the name of the current activity/fragment    
    mTracker.setScreenName("Screen name: " + TAG); //added line
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    super.onResume();
}