kapa.ai how to create a new property in user profile in mixpanel
To create a new property in a user profile in Mixpanel, you need to use the appropriate method for your SDK. Here's how to do it across different platforms:
JavaScript
// First identify the user
mixpanel.identify('12345');
// Set a new property on the user profile
mixpanel.people.set({
plan: 'Premium'
});
// You can set multiple properties at once
mixpanel.people.set({
plan: 'Enterprise',
company: 'mixpanel'
});
React Native
// Identify the user first
mixpanel.identify('12345');
// Set a single property
mixpanel.getPeople().set('plan', 'Premium');
// Or set multiple properties at once
let properties = {'plan':'Premium','company':'mixpanel'};
mixpanel.getPeople().set(properties);
Swift (iOS)
// Identify the user first
Mixpanel.mainInstance().identify(distinctId: "12345")
// Set properties
Mixpanel.mainInstance().people.set(properties: ["plan":"Premium", "$email":"joe.doe@โ[example.com](http://example.com)"])
Node.js
// Initialize Mixpanel
const Mixpanel = require('mixpanel');
const mp = Mixpanel.init('YOUR_PROJECT_TOKEN');
// Create a user profile with properties
mp.people.set('sample_distinct_id', {
name: 'sam',
plan: 'premium',
ip: '0' // do not update geolocation
});
Important Notes:
1. You must call identify() before setting profile properties (for client-side SDKs)
2. If a profile property already exists, it will be overwritten with the new value
3. If a profile property does not exist, it will be added to the profile
4. For server-side SDKs (Node.js, PHP, Ruby, Go), consider setting IP to 0 to prevent geolocation updates from your server's location
The exact method name varies slightly between SDKs (e.g., people.set() in JavaScript, getPeople().set() in React Native), so refer to the documentation for your specific platform.
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.
