# Screen events
User.com SDK can automatically tracks user activity across the app. It is related to your app lifecycle, e.g. orientation changes, open/close application, switching between activities(going through one to another mobile screen). You can also manually track Activities (if you don’t set UserCom.Builder.trackAllActivities()
) and Fragments using UserCom.getInstance().trackScreen()
function.
The following screen events are available to be sent:
activity created
activity started (with intent arguments)
activity stopped
fragment created
fragment started (with arguments)
fragment stopped
Manually screen tracking
You can manually enable screen tracking for specific support Activity (AppCompatActivity, FragmentActivity, etc.) or Fragment. To do this invoke
trackScreen()
inonCreate()
. From this time lifecycle(created, started, stopped) will be tracked.
public class MainActivity extends FragmentActivity {
@Override
public void onCreate() {
super.onCreate();
UserCom.getInstance().trackScreen(this);
}
}
Changing screen name
To define custom screen name (screen name that will appear in request) annotate activity class with @ScreenName
annotation and name
argument.
If you don’t provide @ScreenName
annotation then default value for this fragment will be SplashFragment.class.getSimpleName()
.
@ScreenName(name = "main_activity")
public class SplashFragment extends Fragment {
…
}
Track screen arguments
Use @TrackArguments
annotation to start screen arguments tracking (keys and values). For Activities, it’ll be passed intents and for Fragments passed arguments. By default, all values will be sent. To specify which intent keys should be tracked, put them into annotation array:
@TrackArguments(intents = {MainActivity.INTENT_KEY1, MainActivity.INTENT_KEY2})
public class MainActivity extends Activity {
public static final String INTENT_KEY1 = "INTENT_KEY1";
public static final String INTENT_KEY2 = "INTENT_KEY2";
}