Use FlurryAgent.onEvent(String eventId, Map parameters)

后端 未结 2 1134
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 23:10

Please anybody tell how to use

FlurryAgent.onEvent(String eventId, Map parameters)

in an android activity to track events

相关标签:
2条回答
  • 2021-02-07 23:51

    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!

    0 讨论(0)
  • 2021-02-08 00:12

    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.

    0 讨论(0)
提交回复
热议问题