使用的说明:https://developers.google.com/analytics/devguides/collection/android/v3/
管理的界面:http://www.google.com/analytics/
GA的jar包地址:http://download.csdn.net/detail/baidu_nod/7695345
代码里这样来用
在每个Activity的onstart里面:
EasyTracker.getInstance(this).activityStart(this); // Add this method.
在每个Activity的onstop里面:
EasyTracker.getInstance(this).activityStop(this); // Add this method.
如果要记录一个事件:
EasyTracker easyTracker = EasyTracker.getInstance(this);
easyTracker.send(MapBuilder
.createEvent("event category", // Event category (required)
"event action", // Event action (required)
"event value", // Event label
null) // Event value
.build());
如果想加一些参数可以使用customDimension:
EasyTracker easyTracker = EasyTracker.getInstance(context);
//"aa"为customDimension
easyTracker.set(Fields.customDimension(1),"aa");
easyTracker.set(Fields.customDimension(2),"bb");
easyTracker.set(Fields.customDimension(3),"cc");
easyTracker.send(MapBuilder
.createEvent("Event category", // Event category (required)
"Event action", // Event action (required)
"event label", // Event label
null) // Event value
.build());
这个是实时记录事件的,很好用