Google Event Tracker v3

I have a problem with Google Tracker. After the official Google documentation to develop documentation I add an xml file with my identifier. After that, I create a new Tracker and try to push a new event, but the "sendevent" method does not exist.

this is my code

Import:

import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.GoogleAnalytics;
import com.google.analytics.tracking.android.Tracker;

// I think I need to import the tracker

and simple code

 Long opt_value;
          Tracker MyTracker;
           MyTracker.sendEvent("ui_action", "button_press", "play_button", opt_value);

And the error:

The method sendEvent(String, String, String, Long) is undefined for the type Tracker

Thanks everyone and sorry for my bad english

Edit: Now I'm trying with

  MyTracker.send(MapBuilder
      .createEvent("evt",    
                   "Id",    
                   ""+idSong,       
                   null).build()
  );  

but on logcat I have: 08-20 10: 45: 35.320: I / GAV3 (5371): Thread [GAThread, 5, main]: No campaign data found.

+3
source share
1 answer

sendEvent, , :

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);

V2 lib, V3:

  // 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()
    );
+2

All Articles