public static interface MixpanelAPI.People
MixpanelAPI.getPeople()
The People object is used to update properties in a user's People Analytics record.
For this reason, it's important to call identify(String) on the People
object before you work with it. Once you call identify, the user identity will
persist across stops and starts of your application, until you make another
call to identify using a different id.
A typical use case for the People object might look like this:
public class MainActivity extends Activity {
MixpanelAPI mMixpanel;
public void onCreate(Bundle saved) {
mMixpanel = MixpanelAPI.getInstance(this, "YOUR MIXPANEL API TOKEN");
mMixpanel.identify("A UNIQUE ID FOR THIS USER");
...
}
public void userUpdatedJobTitle(String newTitle) {
mMixpanel.getPeople().set("Job Title", newTitle);
...
}
public void onDestroy() {
mMixpanel.flush();
super.onDestroy();
}
}
MixpanelAPI| Modifier and Type | Method and Description |
|---|---|
void |
append(java.lang.String name,
java.lang.Object value)
Appends a value to a list-valued property.
|
void |
clearCharges()
Permanently clear the whole transaction history for the identified people profile.
|
void |
deleteUser()
Permanently deletes the identified user's record from People Analytics.
|
java.lang.String |
getDistinctId()
Deprecated.
in 6.2.0
NOTE: This method is deprecated. Please use
MixpanelAPI.getDistinctId() instead. |
void |
identify(java.lang.String distinctId)
Deprecated.
in 6.2.0
NOTE: This method is deprecated. Please use
MixpanelAPI.identify(String) instead. |
void |
increment(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
Change the existing values of multiple People Analytics properties at once.
|
void |
increment(java.lang.String name,
double increment)
Add the given amount to an existing property on the identified user.
|
boolean |
isIdentified()
Checks if the people profile is identified or not.
|
void |
merge(java.lang.String name,
org.json.JSONObject updates)
Merge a given JSONObject into the object-valued property named name.
|
void |
remove(java.lang.String name,
java.lang.Object value)
Remove value from a list-valued property only if they are already present in the list.
|
void |
set(org.json.JSONObject properties)
Set a collection of properties on the identified user all at once.
|
void |
set(java.lang.String propertyName,
java.lang.Object value)
Sets a single property with the given name and value for this user.
|
void |
setMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Set a collection of properties on the identified user all at once.
|
void |
setOnce(org.json.JSONObject properties)
Like
set(String, Object), but will not set properties that already exist on a record. |
void |
setOnce(java.lang.String propertyName,
java.lang.Object value)
Works just like
set(String, Object), except it will not overwrite existing property values. |
void |
setOnceMap(java.util.Map<java.lang.String,java.lang.Object> properties)
Like
set(String, Object), but will not set properties that already exist on a record. |
void |
trackCharge(double amount,
org.json.JSONObject properties)
Track a revenue transaction for the identified people profile.
|
void |
union(java.lang.String name,
org.json.JSONArray value)
Adds values to a list-valued property only if they are not already present in the list.
|
void |
unset(java.lang.String name)
permanently removes the property with the given name from the user's profile
|
MixpanelAPI.People |
withIdentity(java.lang.String distinctId)
Return an instance of Mixpanel people with a temporary distinct id.
|
@Deprecated void identify(java.lang.String distinctId)
MixpanelAPI.identify(String) instead.distinctId - a String that uniquely identifies the user. Users identified with
the same distinct id will be considered to be the same user in Mixpanel,
across all platforms and devices. We recommend choosing a distinct id
that is meaningful to your other systems (for example, a server-side account
identifier)MixpanelAPI.identify(String)void set(java.lang.String propertyName,
java.lang.Object value)
propertyName - The name of the Mixpanel property. This must be a String, for example "Zip Code"value - The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"void setMap(java.util.Map<java.lang.String,java.lang.Object> properties)
properties - a Map containing the collection of properties you wish to apply
to the identified user. Each key in the Map will be associated with
a property name, and the value of that key will be assigned to the property.
See also set(org.json.JSONObject)void set(org.json.JSONObject properties)
properties - a JSONObject containing the collection of properties you wish to apply
to the identified user. Each key in the JSONObject will be associated with
a property name, and the value of that key will be assigned to the property.void setOnce(java.lang.String propertyName,
java.lang.Object value)
set(String, Object), except it will not overwrite existing property values. This is useful for properties like "First login date".propertyName - The name of the Mixpanel property. This must be a String, for example "Zip Code"value - The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"void setOnceMap(java.util.Map<java.lang.String,java.lang.Object> properties)
set(String, Object), but will not set properties that already exist on a record.properties - a Map containing the collection of properties you wish to apply
to the identified user. Each key in the Map will be associated with
a property name, and the value of that key will be assigned to the property.
See also setOnce(org.json.JSONObject)void setOnce(org.json.JSONObject properties)
set(String, Object), but will not set properties that already exist on a record.properties - a JSONObject containing the collection of properties you wish to apply
to the identified user. Each key in the JSONObject will be associated with
a property name, and the value of that key will be assigned to the property.void increment(java.lang.String name,
double increment)
name - the People Analytics property that should have its value changedincrement - the amount to be added to the current value of the named propertyincrement(Map)void merge(java.lang.String name,
org.json.JSONObject updates)
name - the People Analytics property that should have the update merged into itupdates - a JSONObject with keys and values that will be merged into the propertyvoid increment(java.util.Map<java.lang.String,? extends java.lang.Number> properties)
If the user does not already have the associated property, the amount will be added to zero. To reduce a property, provide a negative number for the value.
properties - A map of String properties names to Long amounts. Each
property associated with a name in the map will have its value changed by the given amountincrement(String, double)void append(java.lang.String name,
java.lang.Object value)
name - the People Analytics property that should have it's value appended tovalue - the new value that will appear at the end of the property's listvoid union(java.lang.String name,
org.json.JSONArray value)
name - name of the list-valued property to set or modifyvalue - an array of values to add to the property value if not already presentvoid remove(java.lang.String name,
java.lang.Object value)
name - the People Analytics property that should have it's value removed fromvalue - the value that will be removed from the property's listvoid unset(java.lang.String name)
name - name of a property to unsetvoid trackCharge(double amount,
org.json.JSONObject properties)
amount - the amount of money exchanged. Positive amounts represent purchases or income from the customer, negative amounts represent refunds or payments to the customer.properties - an optional collection of properties to associate with this transaction.void clearCharges()
void deleteUser()
Calling deleteUser deletes an entire record completely. Any future calls to People Analytics using the same distinct id will create and store new values.
boolean isIdentified()
@Deprecated java.lang.String getDistinctId()
MixpanelAPI.getDistinctId() instead.set(String, Object) and increment(String, double).
If no calls to MixpanelAPI.identify(String) have been made, this method will return null.identify(String),
MixpanelAPI.getDistinctId()MixpanelAPI.People withIdentity(java.lang.String distinctId)
distinctId - Unique identifier (distinct_id) that the people object will haveMixpanelAPI.People with the specified distinct_id