want to track unsuccessful login by same user, context user is known using an output received in the downstream app so we know who the user is just that they cannot gain access, another context the user ID used for known user cannot be used for users with registration issue. Tracking code is added to the entry point page but does not rely on the user clicking on anything, the action has been done in the previous system before landing on the downstream app, hence why there is a data point to reference. How do I create an event that capture this scenario for same user
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
To track unsuccessful login attempts for a known user in Mixpanel, you should send a custom event (e.g., "Unsuccessful Login") with the user's identifier as a property. Since you know the user’s ID from the upstream system—even if they cannot log in—you can include this ID in the event properties, but you should not call .identify() unless the user is authenticated (logged in), as per Mixpanel best practices.Here’s how you can approach this: 1. Do not call .identify() for users who have not successfully logged in. Only call .identify() for authenticated users to avoid incorrectly merging anonymous and authenticated states, and to prevent issues with users who have registration problems or cannot log in [source].2. Track the event with the user ID as a property. You can send an event like "Unsuccessful Login" and include the known user ID as a property (e.g., attempted_user_id). This allows you to analyze unsuccessful login attempts by user without merging their anonymous and authenticated identities.Example (JavaScript SDK):Summary:
- Track the "Unsuccessful Login" event with the attempted user ID as a property.
- Do not call .identify() or set $user_id for unauthenticated or registration-failed users.
- This approach keeps your identity clusters clean and allows you to analyze failed login attempts by user reference.For more details, see the guidance on when to call .identify() and how to handle user identity in Mixpanel [source].
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.
Let me check the knowledge base for you again. One moment! 📚
If you have two identifiers for a user—one is the canonical user ID (used with .identify()), and the other is a unique identifier like user_guid (not used with .identify())—the recommended approach in Mixpanel is: - Use the canonical user ID (e.g., database ID) with .identify() only when the user is authenticated (logged in) [Identifying Users (Simplified) - Best Practices]. - For events where the user is not authenticated (e.g., unsuccessful login, registration issues), do not call .identify() and do not set $user_id. Instead, include user_guid as a custom property in your event.Example:Key points: - Only use one unique, unchanging user ID with .identify() and $user_id. - Use other identifiers (like user_guid) as event properties, not as identity properties. - Do not attempt to merge multiple user IDs in Simplified ID Merge, as only one $user_id per cluster is supported [Identifying Users (Simplified) - FAQ].This approach keeps your identity management clean and allows you to analyze events by any identifier you choose, without affecting Mixpanel's user identity resolution.
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.
Let me check the knowledge base for you again. One moment! 📚
markdown
# Mixpanel Event Tracking for Unsuccessful Login Attempts (Using user_guid)LBKS## OverviewLBKSThis document outlines the implementation strategy for tracking unsuccessful login attempts in Mixpanel, specifically when you have two user identifiers: LBKS- **user_id**: The canonical user identifier, used with `.identify()` only after successful authentication.
- **user_guid**: A unique identifier available for all users, including those who have not successfully logged in or registered.LBKSThe goal is to capture unsuccessful login attempts without merging unauthenticated users into the main user identity cluster.LBKS---LBKS## Implementation StepsLBKS### 1. Do **Not** Call `.identify()` for Unauthenticated UsersLBKS- Only call `.identify()` with the canonical user_id **after** a user has successfully logged in or registered.
- For users who have not authenticated (e.g., failed login, registration issues), **do not** call `.identify()` or set `$user_id` [[Best Practices](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-simplified#best-practices)].LBKS### 2. Track the "Unsuccessful Login" EventLBKS- When an unsuccessful login attempt occurs, send a custom event (e.g., `Unsuccessful Login`) to Mixpanel.
- Include `user_guid` as a property in the event payload.
- Do **not** use `user_guid` with `.identify()` or as `$user_id`.LBKS**Example (JavaScript SDK):**LBKS```LBKSmixpanel.track('Unsuccessful Login', {
user_guid: 'the_unique_guid_value'
});LBKS```LBKSLBKS### 3. Analyze by user_guidLBKS- You can use Mixpanel reports to analyze unsuccessful login events by the `user_guid` property.
- This approach allows you to track and troubleshoot failed login attempts without affecting Mixpanel’s identity resolution.LBKS### 4. When to Use `.identify()`LBKS- Only after a user has successfully logged in, call `.identify()` with the canonical `user_id`: LBKS```LBKSmixpanel.identify('canonical_user_id');LBKS```LBKS- From this point, all subsequent events will be associated with the authenticated user [[Best Practices](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-simplified#best-practices)].LBKS---LBKS## Key PointsLBKS- **Never call `.identify()` or set `$user_id` for unauthenticated or registration-failed users.**
- **Always use a custom property (e.g., `user_guid`) for tracking unauthenticated user actions.**
- **Only use the canonical, unchanging user ID with `.identify()` and `$user_id` after authentication.**LBKSThis approach ensures clean identity management and accurate analytics in Mixpanel, as recommended in Mixpanel’s best practices [[Best Practices](https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users-simplified#best-practices)].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.
