我已将谷歌分析添加到我的应用程序中,目的是获取有关您的屏幕的信息并发送自定义事件。
我获得了重复的内容......我也得到了不同的结果: “com.package.app.MainScreen” - 300 次观看和 “主屏幕” - 200 次观看
我有兴趣只跟进活动的自定义名称而不是包。无论如何,因为两者都显示不同的结果?
public class MainScreen extends Activity {
private static final String GA_PROPERTY_ID = "UA-12345678-9";
private static final String SCREEN_LABEL = "Main Screen";
Tracker mTracker;
EasyTracker easyTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);
mTracker = GoogleAnalytics.getInstance(this).getTracker(GA_PROPERTY_ID);
mTracker.set(Fields.SCREEN_NAME, SCREEN_LABEL); // For Custom Name from activity
mTracker.send(MapBuilder.createAppView().build());
easyTracker = EasyTracker.getInstance(this); // Analytics Events
...
easyTracker.send(MapBuilder.createEvent("MainScreen", "Play", category.get(1), null).build()); //AnalyticsEvents
...
}
@Override
public void onStart() {
super.onStart();
EasyTracker.getInstance(this).activityStart(this);
}
@Override
public void onStop() {
super.onStop();
EasyTracker.getInstance(this).activityStop(this);
}
}
和analytics.xml:
<?xml version="1.0" encoding="utf-8" ?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-12345678-9</string>
<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>
</resources>