Use FlurryAgent.onEvent(String eventId, Map<String, String> parameters)
Asked Answered
N

2

12

Please anybody tell how to use

FlurryAgent.onEvent(String eventId, Map<String, String> parameters)

in an android activity to track events with flurry ?

Nutbrown answered 10/6, 2010 at 10:29 Comment(0)
A
22

The simplest use of onEvent is without parameters.

Let's say we're writing a game and you want to track how many people start the game and how many complete it. You would then have:

FlurryAgent.onEvent("Started game");

and

FlurryAgent.onEvent("Won game");

at appropriate points in your code.

If you want to know more information about the state of the application when an event occurred, you can add parameters to track additional information like this:

HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("Final score", String.valueOf(score));
parameters.put("Time taken", String.valueOf(secondsElapsed));
FlurryAgent.onEvent("Won game", parameters);

You can have up to 100 different event names, each with up to 10 parameters whose names and values are up to 255 characters long.

Notice you don't specify your Flurry ID when calling onEvent. Flurry derives the ID from the current session, so calls to onEvent must be made somewhere between calls to onStartSession and onEndSession - but if you follow their guidelines and put these in your Activity's onStart and onStop then you don't have to worry about that.

Atmo answered 10/12, 2010 at 21:47 Comment(0)
S
6

I show you a simple example. In this code i want to log simple events and other events with a category.

public void logAnalyticsEvent(final String versionName, final String strMsg, final String category){

        if (category==null){                
            FlurryAgent.logEvent(strMsg);           

        }else{              
            final HashMap<String, String> parameters = new HashMap<String, String>();
            parameters.put("Event",strMsg );
            FlurryAgent.logEvent(category, parameters);
        }


}

in the first part of the condition i'm logging the only the event, in the second part I put the name of the event inside de parameters (a hashmap with a key named "Event" and value the name of the event) and I log the name of the category with the parameters (events inside)

FlurryAgent.logEvent(category, parameters);

Hope this helps!

Saito answered 25/10, 2011 at 20:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.