Mxpanel.People (Mxpanel v0.3.0) View Source

Functions to manipulate user profiles.

Shared Options

All of the functions in this module accept the following options:

  • :ip - IP address to get automatic geolocation info.

  • :ignore_time - Prevent the $last_seen property from incorrectly updating user profile properties with misleading timestamps in server-side Mixpanel implementations.

  • :time - Specific timestamp in seconds of the event. Defaults to System.os_time(:second).

Link to this section Summary

Functions

Appends the item to a list associated with the corresponding property name. Appending to a property that doesn't exist will result in assigning a list with one element to that property.

Permanently delete the profile from Mixpanel, along with all of its properties.

Increment the value of a user profile property. When processed, the property values are added to the existing values of the properties on the profile. If the property is not present on the profile, the value will be added to 0. It is possible to decrement by calling with negative values.

Removes an item from a existing list on the user profile. If it does not exist, no updates are made.

Sets properties for a profile identified by its distinct_id. If the profile does not exist, it creates it with these properties. If it does exist, it sets the properties to these values, overwriting existing values.

Works just like set/4 except it will not overwrite existing property values. This is useful for properties like "First login date".

Takes a list of property names, and permanently removes the properties and their values from a profile.

Link to this section Functions

Link to this function

append_item(client, distinct_id, property, item, opts \\ [])

View Source

Specs

append_item(Mxpanel.Client.t(), String.t(), String.t(), String.t(), Keyword.t()) ::
  :ok | {:error, term()}

Appends the item to a list associated with the corresponding property name. Appending to a property that doesn't exist will result in assigning a list with one element to that property.

Mxpanel.People.append_item(client, "13793", "Items purchased", "socks")
Link to this function

delete(client, distinct_id, opts \\ [])

View Source

Specs

delete(Mxpanel.Client.t(), String.t(), Keyword.t()) :: :ok | {:error, term()}

Permanently delete the profile from Mixpanel, along with all of its properties.

Mxpanel.People.delete(client, "13793")

If you have duplicate profiles, set ignore_alias to true so that you don't delete the original profile when trying to delete the duplicate.

Mxpanel.People.delete(client, "user@mail.com", ignore_alias: true)
Link to this function

increment(client, distinct_id, property, amount, opts \\ [])

View Source

Specs

increment(Mxpanel.Client.t(), String.t(), String.t(), String.t(), Keyword.t()) ::
  :ok | {:error, term()}

Increment the value of a user profile property. When processed, the property values are added to the existing values of the properties on the profile. If the property is not present on the profile, the value will be added to 0. It is possible to decrement by calling with negative values.

Mxpanel.People.increment(client, "13793", "Number of Logins", 12)
Link to this function

remove_item(client, distinct_id, property, item, opts \\ [])

View Source

Specs

remove_item(Mxpanel.Client.t(), String.t(), String.t(), String.t(), Keyword.t()) ::
  :ok | {:error, term()}

Removes an item from a existing list on the user profile. If it does not exist, no updates are made.

Mxpanel.People.append_item(client, "13793", "Items purchased", "t-shirt")
Link to this function

set(client, distinct_id, properties, opts \\ [])

View Source

Specs

set(Mxpanel.Client.t(), String.t(), map(), Keyword.t()) ::
  :ok | {:error, term()}

Sets properties for a profile identified by its distinct_id. If the profile does not exist, it creates it with these properties. If it does exist, it sets the properties to these values, overwriting existing values.

properties = %{"Address" => "1313 Mockingbird Lane", "Birthday" => "1948-01-01"}
Mxpanel.People.set(client, "13793", properties)
Link to this function

set_once(client, distinct_id, properties, opts \\ [])

View Source

Specs

set_once(Mxpanel.Client.t(), String.t(), map(), Keyword.t()) ::
  :ok | {:error, term()}

Works just like set/4 except it will not overwrite existing property values. This is useful for properties like "First login date".

properties = %{"First login date" => "2013-04-01T13:20:00"}
Mxpanel.People.set_once(client, "13793", properties)
Link to this function

unset(client, distinct_id, property_names, opts \\ [])

View Source

Specs

unset(Mxpanel.Client.t(), String.t(), [String.t()], Keyword.t()) ::
  :ok | {:error, term()}

Takes a list of property names, and permanently removes the properties and their values from a profile.

property_names = ["Address", "Birthday"]
Mxpanel.People.unset(client, "13793", property_names)