You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

Measuring Non User Initiated Events in Android Apps

4.00 avg. rating (85% score) - 1 vote
We use Google Analytics to measure events like button clicks and generation of notifications etc… in our apps. With the help of this data we get to know how people are using our product, which enables us to identify areas of improvement and maximize the success of product in market. 
Post publishing a version of the android app, we saw a spike in both the number of active users and sessions (in Google Analytics). However, at the same time we witnessed a decrease in the screen views/session. On investigating further, we found that since we are logging (in Google Analytics) some events from background services, Google Analytics mistakes it for a user opening the app. 
So, how to track events that are not part of measured user behavior, like, an event from a background service. Initially we thought of creating a separate tracker for background services but we knew managing multiple trackers in long run will be a task. Exploring further we came across Non-Interaction Hits. It allows a hit to be considered non interactive and thus prevents certain metrics from getting affected.
Thus, a non user initiated event is sent as,
 
Tracker tracker = ((MyApplication) getActivity().getApplication()).getTracker(
      TrackerName.APP_TRACKER);
      tracker.send(new HitBuilders.EventBuilder().setCategory(category)
                 .setAction(action).setLabel(label).setValue(optionalValue).setNonInteraction(true)
                 .build());
 
And a user initiated event as,
Tracker tracker = ((MyApplication) getActivity().getApplication()).getTracker(
      TrackerName.APP_TRACKER);
      tracker.send(new HitBuilders.EventBuilder().setCategory(category)
                 .setAction(action).setLabel(label).setValue(optionalValue)
                 .build());
 
Thus by sending user initiated and non-user initiated events as two different event types, we can get the correct value of Active Users of an application.

One thought on “Measuring Non User Initiated Events in Android Apps

Comments are closed.