0

I am tracking android app activity screens under custom label. However, in the GA dashboard, activities are shown with their default path along with custom labels. Also the metric numbers being tracked under two labels of the same activity are different. Attached is a screen shot for better illustration: enter image description here Here the MainActivity and Home screen are referring the same activity. But GA shows two separate labels. How can I get rid of one MainActivity label?

user1036908
  • 831
  • 1
  • 12
  • 16

2 Answers2

1

You probably have enabled automatic screen tracking. Turn it off and it should disappear.

See here for the description of the property if you use xml or here if you initialize it programmatically.

David Medenjak
  • 33,993
  • 14
  • 106
  • 134
0

You can turn off automatic screen tracking by using enableAutoActivityTracking(false) in code:

https://developers.google.com/android/reference/com/google/android/gms/analytics/Tracker#enableAutoActivityTracking(boolean)

Or via the XML file:

<bool name="ga_autoActivityTracking">false</bool>

https://developers.google.com/analytics/devguides/collection/android/v4/screens#automatic

Tracking things manually can be done using these:

fun trackScreen(context: Context, screenObject: Any, screenName: String? = null) {
        if (screenName == null)
            trackScreen(context, screenObject.javaClass)
        else
            trackScreen(context, screenObject.javaClass, screenName)
    }

fun trackScreen(context: Context, clazz: Class<Any>, screenName: String = clazz.simpleName) {
        if (BuildConfig.DEBUG)
            return
        val className = clazz.canonicalName ?: clazz.name
        FirebaseAnalytics.getInstance(context).logEvent(FirebaseAnalytics.Event.SCREEN_VIEW) {
            param(FirebaseAnalytics.Param.SCREEN_NAME, screenName)
            param(FirebaseAnalytics.Param.SCREEN_CLASS, className)
        }
    }

So you can use registerActivityLifecycleCallbacks and use the above function, for example:

https://developer.android.com/reference/android/app/Application#registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)

android developer
  • 114,585
  • 152
  • 739
  • 1,270