我的 Google Analytics 有问题,它显示我的屏幕名称是这样的:
package.class
但我只想要类(class)名称,所以我在类(class)中这样做了:
@Override
public void onResume() {
super.onResume();
final Tracker tracker = ((App) this.getApplication()).getTracker();
if(tracker != null){
tracker.setScreenName(getClass().getSimpleName());
tracker.send(new HitBuilders.ScreenViewBuilder().build());
}
}
但在 Google Analytics 中,我得到了 2 倍的 Screen 和 2 个不同的名称:
package.class
class
应用程序.java:
private static final String TAG = "App";
public synchronized Tracker getTracker() {
try {
final GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(this);
return googleAnalytics.newTracker(R.xml.app_tracker);
}catch(final Exception e){
Log.e(TAG, "Failed to initialize Google Analytics V4");
}
return null;
}
只有类名怎么办?
最佳答案
也许你可以在你的 app_tracker.xml 中尝试:
<!-- If ga_autoActivityTracking is enabled, an alternate screen name can be specified to
substitute for the full length canonical Activity name in screen view hit. In order to
specify an alternate screen name use an <screenName> element, with the name attribute
specifying the canonical name, and the value the alias to use instead. -->
<screenName name="com.example.ActivityMain">Home activity</screenName>
关于android - 为 Google Analytics 设置屏幕名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31722754/