Google Event Tracker v3

戏子无情 提交于 2019-12-05 18:37:40

To use sendEvent method you should first initialize the tracker like:

private static Tracker m_GaTracker;
private GoogleAnalytics m_GaInstance;
m_GaInstance = GoogleAnalytics.getInstance(context);
m_GaTracker = m_GaInstance.getTracker("UA---");
m_GaInstance.setDefaultTracker(m_GaTracker);
m_GaTracker.sendEvent("your value ", " ", " ", 0L);

The above code works with V2 lib , to work with V3 use:

  // Instead, send a single hit with session control to start the new session.
    mTracker.send(MapBuilder
      .createEvent("UX", "appstart", null, null)
      .set(Fields.SESSION_CONTROL, "start")
      .build()
    );
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!