Mixpanel Community Icon

Understanding Device ID Consistency During User Interaction Without Login

·
·

What if the first two screen a user interacts with the user has not logged in yet making only the anonymous device id available to track the user activity but there are instances where across both page interacted by the user it maintains the same device ID and for other instances it does not. What could be the reason for this? What explains why the device IDs is not changing as the user moves from screen 1 to screen 2

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

    Hi event, 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
    ·
    ·

    When a user interacts with your app or website before logging in, Mixpanel’s SDK automatically generates and persists a unique anonymous device ID ($device_id) for that user. All events tracked during this anonymous session are associated with this $device_id. If the same $device_id is maintained across both screens (screen 1 and screen 2): - This is the expected behavior. The SDK is designed to persist the $device_id in local storage or cookies, so as long as the session or storage is not cleared, the same device ID will be used for all anonymous events from that device/browser/session. This allows Mixpanel to attribute all pre-login activity to the same anonymous user, even across multiple screens or page views within the same session Managing User Identity Identifying Users (Simplified) - Client-side.If the $device_id changes between screens: - This is not the default behavior and usually indicates an issue with how the SDK is persisting the device ID. Possible reasons include: - The app or website is clearing local storage or cookies between screens, causing the SDK to generate a new $device_id for each screen. - The SDK is being re-initialized in a way that does not preserve the previous state. - The user is switching between different browsers, incognito/private modes, or devices, each of which would have its own $device_id. - There is a manual override or misconfiguration in your implementation that resets or changes the device ID between screens.Summary: The device ID should remain the same as the user moves from screen 1 to screen 2 within the same session and device. If it does not, it is likely due to storage being cleared, SDK re-initialization, or a similar implementation issue. Ensuring that local storage or cookies are not cleared and that the SDK is initialized consistently will help maintain the same device ID across screens for anonymous users Identifying Users (Simplified) - Example User Flows Managing User Identity.

    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.

  • Avatar of event
    event
    ·
    ·

    Could VPN also cause this please tell me I’m wrong if so and do not just agree with me kapa.ai

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

    Let me check the knowledge base for you again. One moment! 📚

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

    Based on the information in the knowledge sources, there is no mention that using a VPN would cause the Mixpanel $device_id to change between screens for an anonymous user. The $device_id is generated and persisted by the Mixpanel SDK in local storage or cookies on the client device, and is not tied to the user's IP address or geolocation. Therefore, using a VPN should not affect the $device_id value as the user moves between screens.If you are seeing $device_id change between screens, it is more likely due to issues such as clearing local storage/cookies, SDK re-initialization, or switching browsers/devices—not because of VPN usage Identifying Users (Simplified) - Client-side Identity Management.So, you are correct: VPN usage should not cause the $device_id to change.

    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.

  • Avatar of event
    event
    ·
    ·

    How does that work? Clearing local storage is this even possible? kapa.ai

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

    Let me check the knowledge base for you again. One moment! 📚

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

    Yes, clearing local storage (or cookies) is possible and can affect how Mixpanel tracks anonymous users. According to the knowledge sources, Mixpanel’s SDK stores the $device_id in local storage or cookies on the client device. If this storage is cleared—either manually by the user, programmatically by your app, or due to browser settings—the SDK will generate a new $device_id the next time it initializes. This results in a new anonymous identity for the user, even if they are on the same device and browser.This is explicitly mentioned in the documentation: > "Calling .reset will clear the local storage (which contains the $user_id and $device_id), and generate a new $device_id for the session."

    — Identifying Users (Simplified) - Client-side Identity ManagementSo, if local storage or cookies are cleared between screens, Mixpanel will not be able to persist the same $device_id, and a new one will be created. This is a key reason why you might see the device ID change unexpectedly.

    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.

  • Avatar of event
    event
    ·
    ·

    What are other reasons for this device ID change? kapa.ai

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

    Let me check the knowledge base for you again. One moment! 📚

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

    Other reasons for a device ID ($device_id) change, according to the knowledge sources, include: - Calling .reset(): Explicitly calling the .reset() method in your Mixpanel SDK will clear the local storage (which contains the $device_id) and generate a new $device_id for the session. This is recommended when a user logs out or when there is an explicit intent to change to a new user on the same device Identifying Users (Simplified) - Client-side Identity Management.- Switching Devices or Browsers: Each device and browser maintains its own local storage or cookies. If a user switches to a different device or browser, a new $device_id will be generated for that environment Identifying Users (Simplified) - Example User Flows.- Incognito/Private Browsing Mode: Using incognito or private browsing mode can result in a new $device_id for each session, as local storage and cookies are typically cleared when the session ends.- Manual or Programmatic Clearing of Storage: If your application or the user manually clears cookies or local storage, the persisted $device_id will be lost, and a new one will be generated on the next initialization Identifying Users (Simplified) - Client-side Identity Management.If you are seeing unexpected changes in $device_id, these are the primary reasons documented. There is no mention in the knowledge sources of VPN usage causing a device ID change.

    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.