代码示例:
//在应用程序的主Activity中配置Google Analytics SDK public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
//初始化Google Analytics SDK
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
Tracker tracker = analytics.newTracker("UA-XXXXX-Y");
//发送事件
tracker.send(new HitBuilders.EventBuilder()
.setCategory("category")
.setAction("action")
.setLabel("label")
.setValue(1)
.build());
}
}