where do i set the user properties within my apps code?
Hi Laurenz H., 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 set user properties in your app's code using Mixpanel, you need to use the people.set()
method (or its equivalent depending on the SDK you're using). The exact implementation varies slightly depending on the programming language and SDK you're using. Here are some examples:For JavaScript:LBKSmixpanel.identify('USER_ID');LBKSmixpanel.people.set({ '$name': 'Jane Doe', '$email': 'jane.doe@​[example.com](http://example.com)', 'plan' : 'Premium' // Add any other user properties here });LBKS
For iOS (Swift)::LBKS```LBKSMixpanel.mainInstance().identify(distinctId:: "USER_ID")Mixpanel.mainInstance().people.set(properties: [
"email"::"jane.doe@​[example.com](http:://example.com)",
"name", "Jane Doe");
mixpanel.getPeople().set("$email", "jane.doe@​example.com");
mixpanel.getPeople().set("plan", "Premium");```Remember to replace "USER_ID" with the actual unique identifier for your user, preferably the user ID from your database.It's important to note that you should call identify()
before setting user properties to associate the profile update with the correct user.For more detailed information and examples for other SDKs, you can refer to the following Mixpanel documentation:Mixpanel SDKs: Javascript
Mixpanel SDKs: iOS (Swift)
Mixpanel SDKs: Android
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.
and hows does this work? I set this one time and then every user will be tracked once they get on the app?@kapa.ai