Trackable Actions

Screen Views

Screen Views are some of the simplest and useful data to collect. Assuming that we're using a Screen View is an Activity, we can track this behavior with the following:

/* MainActivity.java*/

@Override
    protected void onResume() {
        super.onResume();

        Map<String, String> data = new HashMap<String, String>(2);
        data.put("screen_title", "main");
        data.put("view_action", "resume");

        TealiumCollect.sendView(data);
    }

    @Override
    protected void onPause() {

        Map<String, String> data = new HashMap<String, String>(2);
        data.put("screen_title", "main");
        data.put("view_action", "pause");

        TealiumCollect.sendView(data);

        super.onPause();
    }

Not only will this setup allow for view counts, but it also equips us to track how much time is spent on every screen.

Button Clicks

Button Clicks (and other UI interactions) too, are simple and useful data to collect; and can be done with the following:

@Override
public void onClick(View v) {

    Map<String, String> data = new HashMap<String, String>(2);
    data.put("event_name", "login");
    data.put("event_action", "click");

    TealiumCollect.sendEvent(data);

    // Perform login...
}

Form Entry

It is easy to overlook user input when establishing visitor behavior. Leveraging Android's OnFocusChangeListener, we can track this data:

@Override
public void onFocusChange(View view, boolean hasFocus) {

    Map<String, String> data = new HashMap<String, String(2);
    data.put("field_name", "comment");
    data.put("field_action", hasFocus ? "focus" : "blur");

    TealiumCollect.sendEvent(data);
}

Don't forget some other user behaviors:

  • Geofencing
  • Beacons
  • Scores
  • Spending
  • Also take a look at our community for more TODO: link

Every application offers something to it's users, so don't forget events unique to your app!