Sarthak Majithia
Sarthak Majithia

Reputation: 301

Flurry "Event" Add

I know how to start and end Sessions in flurry I am also able to successfully see them in my Analytics section.

What I want to implement now is events for user clicks/views.

I have a media player which plays a file. I want to see how many users have played the file till end. How add such events inside a session for a user?

Upvotes: 0

Views: 428

Answers (1)

Sarthak Majithia
Sarthak Majithia

Reputation: 301

Initialize a FlurryAgent after onCreate() using:

FlurryAgent.init(YourClass.this, "YOUR_API_KEY");

Start / End your sessions using: (This will come in your activity class)

@Override
protected void onStart() {
    super.onStart();
    FlurryAgent.onStartSession(YourClass.this, "YOUR_API_KEY");
}

@Override
protected void onStop() {
    super.onStop();
    FlurryAgent.onEndSession(YourClass.this);
}

Now add this line where ever you want to log the event:

FlurryAgent.logEvent("Your_event_name");

To log events with some parameters, use:

HashMap<String, String> myMap = new HashMap<String, String>();
myMap.put("key", "value");
FlurryAgent.logEvent("even_name", myMap);

Hope this will help somebody.

NOTE: If you come across the two terms FlurryAgent.logEvent and FlurryAgent.onEvent, use .logEvent

.onEvent is deprecated. Reference here

Upvotes: 3

Related Questions