Mixpanel Community Icon

Mixpanel Session Management in Mobile App SDK Explained

·
·

how does mixpanel manage session start and end by default in the mobile app sdk ?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Zeyad Y., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Based on the knowledge sources provided, I can explain how Mixpanel manages session start and end by default in the mobile app SDK.Mixpanel's mobile SDKs have a legacy feature to automatically track common mobile events, including session events. However, the documentation recommends disabling this automatic tracking as these events rely on client-side state and can be unreliable.For iOS (Swift), the automatically tracked session event is: LBKS$ae_session (App Session) - Executes when a user spends more than 10 seconds in the app. A Session Length ($ae_session_length) property is tracked to reflect the number of seconds user spent in the session. In addition, there are two user properties tracked: Total App Sessions ($ae_total_app_sessions) and Total App Session Length ($ae_total_app_session_length).LBKSMixpanel SDKs: iOS (Swift)The same behavior is documented for iOS (Objective-C) as well, with the session event triggering after 10 seconds in the app Mixpanel SDKs: iOS (Objective-C).For session recording in iOS, the documentation mentions that recording automatically stops when the app goes to the background. If you want continuous recording, you need to restart the replay once the app becomes active again: LBKSMPSessionReplay.getInstance()?.startRecording()LBKSSession Replay (iOS)Mixpanel also has reserved event properties related to sessions, including: - $event_count (Session Event Count): The number of events during a session - $origin_start (Session Start Event Name): The original event name that triggered Session Start event - $origin_end (Session End Event Name): The original event name that triggered Session End event - $duration_s (Session Duration in Seconds): The duration between Session Start and Session End eventsReserved PropertiesTo disable automatic tracking of these events, you should set trackAutomaticEvents to false during initialization: LBKS// Swift Mixpanel.initialize(token: "YOUR_PROJECT_TOKEN", trackAutomaticEvents: false)LBKS objc // Objective-C [Mixpanel sharedInstanceWithToken:@​"YOUR_PROJECT_TOKEN" trackAutomaticEvents:NO];LBKS

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.