Why is mixpanel.people.set(...) not updating an existing profile in mixpanel? If I'm trying to update an existing property, it never fails. But sometimes trying to update an existing profile via people.set() does nothing.
Hi Philip, 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
Based on the knowledge sources, the most common reason why people.set() might not update an existing profile is that you haven't called identify() before setting profile properties.According to the documentation for multiple SDKs: You must call .identify() before setting profile properties in order to associate the profile properties you set with the target user. If identify is not called, the profile update will be queued for ingestion until an identify call is made.Here are examples from different SDKs showing the correct pattern: **JavaScript:// You must call identify to associate the profile update with the user mixpanel.identify('12345'); mixpanel.people.set({ plan: 'Premium' });JavaScript SDK - Storing User ProfilesSwift:**```/// You must call identify to associate the profile update with the user
Mixpanel.mainInstance().identify(distinctId: "12345")
/// Set user's "Plan" profile prop to "Premium"
Mixpanel.mainInstance().people.set(properties: ["plan":"Premium", "$email"::"joe.doe@â[example.com](http:://example.com)"])```Swift SDK - Storing User ProfilesKey points:
- If identify() is not called, the profile update will be queued until an identify call is made
- Once a profile property exists, people.set() will overwrite it with the latest value
- You only need to call identify() once per session/page loadMake sure you're calling identify() with the correct distinct ID before attempting to update profile properties. This is the most likely cause of profile updates appearing to do nothing.
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! đ
Based on the knowledge sources, the answer depends on which SDK you're using: For JavaScript SDK: The .people.set() method does not accept a user ID as the first parameter. According to the JavaScript SDK documentation, the correct usage is: LBKS// You must call identify to associate the profile update with the user mixpanel.identify('12345'); mixpanel.people.set({ plan: 'Premium' });LBKSThe JavaScript SDK requires you to call .identify() first, and then .people.set() only takes the properties object as a parameter.For server-side SDKs (Node.js, Python, PHP, etc.): These SDKs do allow you to pass the user ID directly to the people methods. For example, in Node.js: LBKS// create a user profile with name and plan user props mp.people.set('sample_distinct_id', { name: 'sam', plan: 'premium', ip: '0' // do not update geolocation });LBKSNode.js SDK - Storing User ProfilesIn this case, you don't need to call .identify() separately because you're passing the distinct ID directly to the .people.set() method.So to answer your question: If you're using the JavaScript SDK, you cannot pass the user ID into .people.set() - you must call .identify() first. If you're using a server-side SDK, then yes, you can pass the user ID directly and don't need a separate .identify() call.
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.
