How can I import a new property for my Users?
Hi João V., 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 import a new property for your Users in Mixpanel, you have several options. Here's a summary of the main methods:1. Using the UI:
You can import user profiles, including new properties, via the Mixpanel UI. This method allows you to import profiles from a CSV file. Importing Profiles via the UI provides detailed instructions on how to do this. When preparing your CSV, remember not to include column headers. Instead, you'll identify column headers through the CSV upload wizard in the Mixpanel UI.2. Using the API:
You can use the HTTP Engage API to set new profile properties. The $set
operator allows you to set a new profile property or update an existing one.Here's a sample Python code to set a new property:LBKS# Fill this out. You can get it from [https://mixpanel.com/settings/project](https://mixpanel.com/settings/project) PROJECT_TOKEN = ""LBKSimport json import requestsLBKSdef get_users_from_database(): # Replace this with code that reads users from your database or CRM. return [ {"user_id": "123", "$name": "Alice", "$email": "alice@[linear.app](http://linear.app)", "department": "engineering"}, {"user_id": "456", "$name": "Bob", "$email": "bob@notion.so", "department": "product"}, {"user_id": "789", "$name": "Carol", "$email": "carol@[figma.com](http://figma.com)", "department": "design"} ]LBKSdef transform_to_mp_format(user): distinct_id = user.pop("user_id") return {"$distinct_id": distinct_id, "$token": PROJECT_TOKEN, "$ip": "0", "$set": user}LBKSusers = get_users_from_database() profiles = [transform_to_mp_format(u) for u in users]LBKSresp = [requests.post](http://requests.post)( "[https://api.mixpanel.com/engage](https://api.mixpanel.com/engage)", params={"verbose": "2"}, headers={"Content-Type": "application/json"}, data=json.dumps(profiles) )LBKSprint(resp.json())LBKS
3. Using SDKs:
If you're using one of Mixpanel's SDKs, you can set new profile properties programmatically. For example, in JavaScript:LBKS// You must call identify to associate the profile update with the user mixpanel.identify('12345'); mixpanel.people.set({ plan: 'Premium' });LBKS
Remember, when setting new properties, it's important to call identify()
first to associate the profile update with the correct user.For more detailed information on these methods, you can refer to:
- Importing Profiles via API
- Storing User Profiles (JavaScript SDK)
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.