Skip to content

Commit

Permalink
add group identifier to user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Myron Fung authored and Myron Fung committed Oct 28, 2024
1 parent 8031484 commit 4a992a4
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 3 deletions.
18 changes: 18 additions & 0 deletions pages/docs/tracking-methods/sdks/android.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,24 @@ mixpanel.addGroup('company', 'mp-us');
mixpanel.track('some_event');
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.getPeople().set()` call.

**Example Usage**

```java Java
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');

```

### Setting Group Profile Properties
Create a group profile by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
16 changes: 16 additions & 0 deletions pages/docs/tracking-methods/sdks/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,22 @@ mixpanel.addGroup('company', 'mp-us');
mixpanel.track('some_event');
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.getPeople().set()` call.

**Example Usage**
```dart
// You must call identify to associate the profile update with the user
// Sets user's "Plan" attribute to "Premium"
mixpanel.identify("12345");
mixpanel.getPeople().set("Plan", "Premium");
// set group key "company" as user prop
// with group id "mixpanel" as the value
mixpanel.getPeople().set("company", "mixpanel");
```

### Setting Group Profile Properties

Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".
Expand Down
26 changes: 26 additions & 0 deletions pages/docs/tracking-methods/sdks/go.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,32 @@ mp.Track(ctx, []*mixpanel.Event{
})
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.PeopleSet` call.

**Example Usage**

```go
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_PROJECT_TOKEN")

// create a payload to create profile for distinct_id 12345
// with group key "company" as user prop and group ID "mixpanel" as value
exampleUser := mixpanel.NewPeopleProperties("12345", map[string]any{
"name": "sam",
"company": "mixpanel",
"$ip": 0
})

// pass the profile payload in the PeopleSet function
err := mp.PeopleSet(ctx,
[]*mixpanel.PeopleProperties{
exampleUser,
},
)
```

### Setting Group Profile Properties
Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
16 changes: 16 additions & 0 deletions pages/docs/tracking-methods/sdks/ios.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,22 @@ Mixpanel *mixpanel = [Mixpanel sharedInstance];
[mixpanel track:@"some_event"];
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `set` call.

**Example Usage**
```objc Objective-C
Mixpanel *mixpanel = [Mixpanel sharedInstance];

// You must call identify to associate the profile update with the user
[mixpanel identify:@"12345"];

// Set group key "company" as user prop
// with group id "mixpanel" as value
[mixpanel.people set:@{@"company": @"mixpanel"}];
```
### Setting Group Profile Properties
Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".
Expand Down
26 changes: 26 additions & 0 deletions pages/docs/tracking-methods/sdks/java.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,32 @@ JSONObject eventPayload =
mixpanel.sendMessage(eventPayload);
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.set()` call.

```java
// import classes from the library
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;

// initialize MessageBuilder and MixpanelAPI
MessageBuilder messageBuilder =
new MessageBuilder("YOUR_PROJECT_TOKEN");

MixpanelAPI mixpanel = new MixpanelAPI();

// create profile update message for "sample_distinct_id"
// with group key "company" as user prop and group id "mixpanel" as value
JSONObject props = new JSONObject();
props.put("company", "mixpanel");
props.put("$ip", "0"); // do not update profile location
JSONObject newUser = messageBuilder.set("sample_distinct_id", props);

// Send the message to mixpanel
mixpanel.sendMessage(newUser);
```

### Setting Group Profile Properties
Create a group profile by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
10 changes: 10 additions & 0 deletions pages/docs/tracking-methods/sdks/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ mixpanel.add_group('company', 'mp-us');
mixpanel.track('some_event');
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `people.set()` call.

```javascript
// set group key "company" as a user prop
// with group id "mixpanel" as value
mixpanel.people.set({"company":"mixpanel"})
```

### Setting Group Profile Properties
Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
20 changes: 20 additions & 0 deletions pages/docs/tracking-methods/sdks/nodejs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ mp.track('some_event', {
});
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `people.set()` call.

**Example Usage**

```javascript
// initialize Mixpanel
const Mixpanel = require('mixpanel');
const mp = Mixpanel.init('YOUR_PROJECT_TOKEN');

// set group key "company" as a user prop
// with group id "mixpanel" as value
mp.people.set('sample_distinct_id', {
name: 'sam',
company: 'mixpanel',
ip: '0'
});
```

### Setting Group Profile Properties
Create a group profile by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
21 changes: 21 additions & 0 deletions pages/docs/tracking-methods/sdks/php.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ $mp->track("some_event", array(
?>
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `set()` call.

**Example Usage**
```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
..
```

## Debug Mode
To enable debug mode, set the `debug` configuration option to `true` when initializing the Mixpanel class.

Expand Down
16 changes: 16 additions & 0 deletions pages/docs/tracking-methods/sdks/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@ mp.track('sample_distinct_id', 'some_event', {
'company' : ['mp-us','mp-eu']})
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `people_set()` call.

**Example Usage**
```python
# initialize Mixpanel
mp = Mixpanel('YOUR_PROJECT_TOKEN')

# set group key "company" as a user prop
# with group id "mixpanel" as value
mp.people_set('sample_distinct_id', {
'name' : 'sam',
'company' : 'mixpanel',
}, meta = {'$ignore_time' : True,'$ip' : 0})

### Setting Group Profile Properties

Create a group profile by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".
Expand Down
16 changes: 16 additions & 0 deletions pages/docs/tracking-methods/sdks/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,22 @@ mixpanel.addGroup('company', 'mp-us');
mixpanel.track('some_event');
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `getPeople().set()` call.

**Example Usage**
```javascript Javascript
// You must call identify to associate the profile update with the user
// Create "plan" profile prop for user "12345"
mixpanel.identify('12345');
mixpanel.getPeople().set('plan', 'Premium');

// set group key "company" as a user prop
// with group id "mixpanel" as value
mixpanel.getPeople().set('company', 'mixpanel');
```

### Setting Group Profile Properties
Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
18 changes: 18 additions & 0 deletions pages/docs/tracking-methods/sdks/ruby.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,24 @@ tracker.track("sample_distinct_id", “some_event”, {
})
```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.people.set()` call.

**Example Usage**
```ruby
# create an instance of the Mixpanel class
require 'mixpanel-ruby'
tracker = Mixpanel::Tracker.new("YOUR_PROJECT_TOKEN")

# set group key "company" as a user prop
# with group id "mixpanel" as value
tracker.people.set('sample_distinct_id', {
'name' => 'Sam',
'company' => 'mixpanel'
}, ip = 0);
```

### Setting Group Profile Properties
Create a group profile by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
17 changes: 17 additions & 0 deletions pages/docs/tracking-methods/sdks/swift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ You can set properties on a user profile with [`people.set(property:to:)`](https

If a profile property already exist, if will be overwritten with the latest value provided in the method. If a profile property does not exist, it will be added to the profile.

**Example Usage**
```swift Swift
/// You must call identify to associate the profile update with the user
Mixpanel.mainInstance().identify(distinctId: "12345")
Expand Down Expand Up @@ -417,6 +418,22 @@ Mixpanel.mainInstance().track(event: "some_event")

```

### Adding Group Identifiers to User Profiles

To connect group information to a user profile, include the `group_key` and `group_id` as a user profile property using the `.people.set()` call.

**Example Usage**

```swift 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":"[email protected]"])

```

### Setting Group Profile Properties
Create a group profiles by setting group properties, similar to a user profile. For example, you may want to describe a company group with properties such as "ARR", "employee_count", and "subscription".

Expand Down
Loading

0 comments on commit 4a992a4

Please sign in to comment.