Automatic Tracking

Prev Next

Automatic tracking is the fastest way to start screen tracking with the Android SDK. It is enabled by default and automatically tracks activities and fragments by generating a page name (also called Content ID) from the class name of the activity or fragment.

When to use Automatic Tracking

Use automatic tracking if you want quick screen coverage with minimal implementation effort. If you need explicit control over page names, events, commerce objects, or media interactions, continue with Manual Tracking.

You can customize or disable automatic tracking for specific screens by using the annotations shown on this page and by adjusting Configure Global Tracking.

Customize Automatic Tracking

Disable tracking for specific screens:
Use the @StopTrack annotation to prevent specific screens or activities from being tracked automatically.

Add page-specific details while keeping automatic tracking enabled:
Use @TrackPageDetail to override the tracked page name or add tracking parameters to a specific screen without switching to a manual page call.

Method Overview

Annotation

Description

@StopTrack

Disables automatic tracking for specific screens or activities.

@TrackPageDetail(
    val contextName: String = "",
    val trackingParams: Array<TrackParams> = []
)

Adds custom parameters to a screen while automatic tracking is enabled. If contextName is empty, the activity name is used. Otherwise, the provided value becomes the tracked page name.

Important Notes

  • Kotlin Support: The @TrackPageDetail annotation works natively with Kotlin and lets you add parameters to specific screens. For Java-based apps, it supports static values only.

  • Avoid Double Tracking: When using automatic tracking, avoid calling trackCustomPage() from Manual Tracking for the same screen, because that can create duplicate page requests and distort analytics.

  • Track events and page parameters in parallel: You can still send events and additional page-related data while automatic tracking is enabled. Use the dedicated manual tracking APIs for those cases when needed.

Examples

Add Custom Page Details

Use @TrackPageDetail to add parameters for a specific page:

@TrackPageDetail (
     contextName = "Main Page" ,
     trackingParams = [TrackParams(Param.INTERNAL_SEARCH, paramVal = "search term" )]
)
class MainActivity : AppCompatActivity() {
}
@TrackPageDetail (
     contextName = "Main Page" ,
     trackingParams = { @TrackParams (paramKey = "is" , paramVal = "new search" )}
 
)
public class MainActivity extends AppCompatActivity() {
}

Note

In Java, you must include the actual key that is sent to Intelligence (for example cp1 if you want to send the value of custom page parameter 1).

Disable Automatic Tracking for a Specific Screen

Use @StopTrack to stop tracking for specific screens:

@StopTrack
class MainActivity : AppCompatActivity() {
}
@StopTrack
public class MainActivity extends AppCompatActivity() {
}