how to identify group property with user identify method?
Hi hanjuuu, 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 connect group information to a user profile in Mixpanel, you need to include the group key and group ID as a user profile property using the appropriate identify or set method depending on the SDK you're using.
Here's how to do it across different Mixpanel SDKs:
JavaScript
// set group key "company" as a user prop
// with group id "mixpanel" as value
mixpanel.people.set({"company":"mixpanel"})
React Native
// You must call identify to associate the profile update with the user
mixpanel.identify('12345');
// set group key "company" as a user prop with group id "mixpanel" as value
mixpanel.getPeople().set('company', 'mixpanel');
Android
MixpanelAPI mixpanel = MixpanelAPI.getInstance(context, 'YOUR_PROJECT_TOKEN', true);
mixpanel.identify('12345', true);
// Sets group key "company" as a user prop with group id "mixpanel" as the value
mixpanel.getPeople().set('company', 'mixpanel');
iOS (Swift)
// You must call identify to associate the profile update with the user
Mixpanel.mainInstance().identify(distinctId: "12345")
// set group key "company" as a user prop with group id "mixpanel" as value
Mixpanel.mainInstance().people.set(properties: ["company":"mixpanel", "$email":"joe.doe@â[example.com](http://example.com)"])
PHP
<?php
// import dependencies
require 'vendor/autoload.php';
// create an instance of the Mixpanel class
$mp = Mixpanel::getInstance("YOUR_PROJECT_TOKEN");
// set group key "company" as a user prop with group id "mixpanel" as value
$mp-> people-> set("USER_ID", array(
'company' => "mixpanel",
), $ip = 0); // set $ip to 0 to prevent profile geolocation update
?>
Remember that you need to have the group key defined in your project settings first before implementing group analytics.
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.
