I have Group Analytics, and the Group Key profile property (in this example, company_id) only retains an array of one value. However, it should retain all company_ids that the user interacts with. How should this be implemented?
Hi Steven J., 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 ensure that the company_id
property in a user's profile retains all company IDs that the user interacts with, you should set the value of the user property as a list of string values. This allows a user to be part of multiple groups within a group key. Here's how you can implement this: 1. Add Group Key to User’s Profile: When adding the <group_key> : <group_id>
to user profiles, ensure that the value is a list of string values. This will connect user profiles to multiple group profiles. For example, if a user interacts with multiple companies, you can set the company_id
property like this:
```LBKSLBKS This setup allows you to view user group profile properties when analyzing by Users in reports, such as when creating user cohorts based on group profile properties.LBKS2. **Use the Appropriate SDK Methods**: Depending on the SDK you are using, ensure that you are using the correct method to add multiple group IDs to a user's profile. For instance, in the React Native SDK, you can use the `.addGroup()` method to add additional group IDs to an existing list.LBKS Example usage in React Native: LBKS
```LBKS // assign the current user to the "mixpanel" company group
mixpanel.setGroup('company', 'mixpanel');
// add "mp-us" as an additional company group
mixpanel.addGroup('company', 'mp-us');
// track "some_event"
// event property "company" = ["mixpanel","mp-us"] is added automatically
mixpanel.track('some_event');
```LBKSLBKSBy following these steps, you can ensure that the `company_id` property retains all company IDs that a user interacts with. For more detailed guidance, you can refer to the [Group Analytics documentation](https://docs.mixpanel.com/docs/data-structure/group-analytics#add-group-key-to-users-profile).
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! đź“š
The mixpanel.addGroup()
function is indeed used to add multiple group IDs to an event. This function allows you to attribute an event to multiple groups by adding additional group IDs to an existing list for a specified group key. This is particularly useful when you want to track events that are associated with multiple groups.Here's an example of how mixpanel.addGroup()
is used in the React Native SDK: LBKS// assign the current user to the "mixpanel" company group mixpanel.setGroup('company', 'mixpanel');LBKS// add "mp-us" as an additional company group mixpanel.addGroup('company', 'mp-us');LBKS// track "some_event" // event property "company" = ["mixpanel","mp-us"] is added automatically mixpanel.track('some_event');LBKS
In this example, the addGroup()
method is used to add "mp-us" to the existing "company" group key, allowing the event to be associated with both "mixpanel" and "mp-us" company groups.For more information, you can refer to the Group Analytics documentation.
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! đź“š
To add multiple group IDs to a user profile, you should set the group key property as a list of string values in the user profile. This allows the user profile to be associated with multiple groups. Here's how you can implement this: 1. Set the Group Key as a List: When updating the user profile, ensure that the group key (e.g., company_id
) is set as an array of group IDs. This will allow the user profile to reflect membership in multiple groups.2. Example Implementation: Depending on the SDK you are using, you can update the user profile with multiple group IDs. Here is an example using the JavaScript SDK:
mixpanel.people.set('sample_distinct_id', {
'company_id': ['1', '2', '3'] // Set multiple group IDs
});
```LBKSLBKS3. **Documentation Reference**: This approach is consistent with the guidance provided in the Mixpanel documentation, which states that a user can be part of multiple groups within a group key by setting the value of the user property as a list of string values. For more details, you can refer to the [Group Analytics documentation](https://docs.mixpanel.com/docs/data-structure/group-analytics#add-group-key-to-users-profile).LBKSBy following these steps, you can ensure that a user profile retains all group IDs that the user is associated with.
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.