SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

How to Disable Automatic Mobile Lifecycle Events in Segment

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 

Have more questions? Submit a request
Powered by Zendesk