Tag events on Android

When an interesting event occurs in your Android application, tag it using these instructions.

Be sure to predefine your events as final static Strings for performance reasons, data actionability, and to avoid collecting any personally identifiable information. Avoid calling this function in a loop so that you don't collect too much data.

You may want to collect additional data about some events, such as how many lives the player has, or what the last action the user took was before clicking on an advertisement. This is accomplished with the second form of tagEvent, which takes a map of key/value pairs, or attributes, along with the event name.

  1. Tag a single event with no attributes by adding the following linex of code, where “Options Saved” is a string describing the event.
    private final static String TAG_OPTIONS_SAVED = "Options Saved";
    public void optionsSaved()
    {
       Localytics.tagEvent(MyApp.TAG_OPTIONS_SAVED);
       // Perform options saved.
    }
    
  2. If you want to add attributes, modify the tag as follows.
    private final static String OPTIONS_SAVED = "Options Saved";
    Map<String, String> values = new HashMap<String, String>();
    values.put(OPTIONS_SAVED, String.valueOf(this.optionsSaved));
    Localytics.tagEvent(MyApp.TAG_OPTIONS_SAVED, values);