Objective
When launching a mobile application using Twilio Segment, you may notice a high volume of anonymous users tracking automatic application lifecycle events (such as Application Opened or Application Backgrounded) before a user login occurs. This article explains whether this behavior is expected, how to disable automatic lifecycle events in your mobile SDK configuration, and best practices for managing anonymous IDs.
Product
Twilio Segment
User Account Permission/Role(s) Required
Developer access to your mobile application's source code.
By default, Twilio Segment's mobile libraries automatically track application lifecycle events and generate an anonymous ID for tracking users before they log in. If you want to disable these automatic lifecycle events, you must modify your SDK initialization instance.
For Kotlin (Android)
To disable automatic tracking, configure the trackApplicationLifecycleEvents setting to false when building your analytics configuration:
Kotlin
val analytics = AnalyticsConfiguration("YOUR_WRITE_KEY")
.trackApplicationLifecycleEvents(false) // Set to false to disable tracking
.build()
For Apple (iOS)
Modify your SDK initialization by adjusting the lifecycle tracking parameters within your configuration setup:
Swift
let configuration = AnalyticsConfiguration(writeKey: "YOUR_WRITE_KEY")
configuration.trackApplicationLifecycleEvents = false // Set to false to disable tracking
Analytics.setup(with: configuration)
Recommendations for Managing Anonymous Users
Expected Behavior: Segment naturally generates an anonymous ID for tracking actions before an identity is established. This helps stitch historical pre-login behavior to a user once they authenticate.
Identify Early: To prevent unlinked anonymous user spikes, trigger an
identify()call as early as possible in the user lifecycle (e.g., immediately upon registration or login).Unintended side effects: Some destinations/downstream providers may require installation and other events provided by lifecycle events for proper attribution later on (as referenced in the Mobile Lifecycle Events link below).
Additional Information
For detailed spec details, see the public documentation on Segment Mobile Lifecycle Events.
-
For library-specific setup updates, review the Segment Kotlin Android Migration Guide and the Segment Apple SDK Migration Guide.