User profile. devtodev SDK for Unity

Additionally to basic methods, you can observe and change the user profiles data. The user profile is the set of properties describing the user. User properties can be divided into 4 groups:

  1. Cross-platform or custom user identifier. If this identifier is not set by the developer, then the device identifier is used.
  2. Automatically collected properties, including data about user's device, geography, app version, SDK, and some other data which can be received from SDK.
  3. A default set of user properties, which can be set by the developer. The set of these parameters works with separate methods. This set includes the data of the user's name, sex, age, e-mail, phone number and URL of user picture. Also, this set includes the mark of a user as a cheater.
  4. Custom set of user properties. In this case, the developer sets any user data he/she needs to know. The data is set in key-value format and can be numeric, string, array or boolean.

You can segment users by all the properties in My Apps section of an application.

Cross-platform user ID

This method is used for user initialization in the applications which are the parts of the cross-platform project.

We recommend you apply this method before the SDK initialization, otherwise, the user identifier from the previous session will be used since the SDK initialization moment till the UserID property call.

If your cross-platform application supposes to be used without cross-platform authorization, don't use the UserID property or use the empty string ("") as the user identifier. SDK will assign the unique identifier to the user. This identifier will we used until the real cross-platform identifier assigns to the user.

Attention! If your application allows user to relogin (changing the user during the working session of application), then the UserID property should be called just after the authorization. You don't need to call the SDK initialization one more time.

/// <summary>
/// Initializes the user with the specified cross-platform identifier
/// property allows to get and to set unique cross-platform user ID used
/// for user identification on your server.</summary>
DevToDev.Analytics.UserId = userId;

​This property also allows you to see which identifier is used at the moment.

Replace Cross-platform user ID

If it is possible to replace the user identifier in your application (say, to make changes in the login/user id for a particular user), use this method at the moment of replacing the identifier.
Attention! Don't use this method if you're going to perform the user's relogin.

/// <summary> Replaces current cross-platform user id. 
/// Attention! Don't use this method if you're going to perform the user's relogin.</summary>
/// <param name="prevUserId"> Old user identifier </param>
/// <param name="userId"> New user identifier </param>
DevToDev.Analytics.ReplaceUserId(string prevUserId, string userId);

Current user level

This method is used in cross-platform applications and applications with data synchronization. 

This method is required for user's level data initialization. We recommend you to use the SetCurrentLevel method just after the user initialization (using the UserID method).

Attention! Don't use the SetCurrentLevel method at the moment of the user's level up. We recommend you to use the levelUp method in this case.

/// <summary> Initializes the current user level. Required if level feature used in the app. </summary>
/// <param name="level"> Сurrent game level of the player </param>
DevToDev.Analytics.SetCurrentLevel(int level);


In case you have your own methods of determining cheaters in the application, you can have such users marked. Payments made by them will not be taken into account in the statistics.

/// <summary> Mark user if it's cheater. </summary>
/// <param name="isCheater"> true if user is a cheater </param>
DevToDev.Analytics.ActiveUser.Cheater = isCheater;



User's name. Default user profile property.

/// <summary> Track user's name </summary>
/// <param name="name"> User’s name </param>
DevToDev.Analytics.ActiveUser.Name = name;



User's age in years. Default user profile property.

/// <summary> Track user's age </summary>
/// <param name="age"> User’s age </param>
DevToDev.Analytics.ActiveUser.Age = age;


User's gender. Default user profile property.

/// <summary> Track user's gender </summary>
/// <param name="gender"> User’s gender. (Unknown, Male, Female) </param>
DevToDev.Analytics.ActiveUser.Gender = gender;


User's e-mail. Default user profile property.

/// <summary> Track user's e-mail </summary>
/// <param name="email"> User’s e-mail </param>
DevToDev.Analytics.ActiveUser.Email = email;

Phone number

User's phone. Default user profile property.

/// <summary> Track user's phone number </summary>
/// <param name="phoneNumber"> User’s phone number </param>
DevToDev.Analytics.ActiveUser.Phone = phoneNumber;


User's photo URL. Default user profile property.

/// <summary> Track user's photo URL </summary>
/// <param name="photoUrl"> User’s photo url </param>
DevToDev.Analytics.ActiveUser.Photo = photoUrl;

Custom user property

Set properties on the current user profile.

/// <summary> Set properties on a user data. </summary>
/// <example> Usage:
/// <code>
///     DevToDev.Analytics.ActiveUser.SetUserData("Hair color", "copper red");
///     //properties can have string, int, double or List<object> type
/// </code>
/// </example>
/// <param name="key">property name</param>
/// <param name="value">a value to set on the given property</param>
DevToDev.Analytics.ActiveUser.SetUserData(string key, object value);

/// <summary> Set multiple properties at once. </summary>
/// <example> Usage:
/// <code>
///     Dictionary<string, object> userData = new Dictionary<string, object>();
///     userData.Add("Hair color", "blonde");
///     userData.Add("Last payment", 100);
///     List<object> lastOrder = List<object>();
///     lastOrder.Add("Coloring");
///     lastOrder.Add("Hair Straightening");
///     userData.Add("Last order", lastOrder);
///     DevToDev.Analytics.ActiveUser.SetUserData(userData);
///     //properties can have string, int, double or List<object> type
/// </code>
/// </example>
/// <param name="userData">an associative array of names and values</param>
DevToDev.Analytics.ActiveUser.SetUserData(Dictionary<string, object> userData);

Increment of the custom property

Increments the given numeric properties by the given values.

/// <summary> Increments or decrements numeric user's properties.</summary>
/// <example> Usage:
/// <code>
///     DevToDev.Analytics.ActiveUser.Increment("Rounds played", 1);
///     //to decrement a counter, pass a negative number
///     DevToDev.Analytics.ActiveUser.Increment("Rounds played", -1);
/// </code>
/// </example>
/// <param name="key">property name</param>
/// <param name="value">an amount to increment the given property(int or double)</param>
DevToDev.Analytics.ActiveUser.Increment(string key, object value);

/// <summary> Increments or decrements multiple numeric user's properties at once.</summary>
/// <example> Usage:
/// <code>
///     Dictionary<string, object> data = new Dictionary<string, object>();
///     data.Add("Rounds played", 1);
///     data.Add("Enemies killed", 6);
///     DevToDev.Analytics.ActiveUser.Increment(data);
/// </code>
/// </example>
/// <param name="values">an associative array of property names and numeric(int, double) values</param>
DevToDev.Analytics.ActiveUser.Increment(Dictionary<string, object>  values);

Append to the custom property

Adds values to a list-valued property. If the property does not currently exist, it will be created with the given list as it's value. If the property exists and is not list-valued, the append will be ignored.

/// <summary> Append values to list properties. </summary>
/// <param name="key"> Property name </param>
/// <param name="value"> Appending value of type {string|int|double|List} </param>
DevToDev.Analytics.ActiveUser.AppendUserData(string key, object value);

/// <summary> Multiple append list-valued properties at once </summary>
/// <param name="values"> An associative array of property names and values </param>
DevToDev.Analytics.ActiveUser.AppendUserData(Dictionary<string, object> values);

Union with custom property

Adds values to a list-valued property only if they are not already present in the list. If the property does not currently exist, it will be created with the given list as it's value. If the property exists and is not list-valued, the union will be ignored.

/// <summary> Union a given list with a list-valued property, excluding duplicate values. </summary>
/// <param name="key"> Property name </param>
/// <param name="value"> Appending value of type {string|int|double|List} </param>
DevToDev.Analytics.ActiveUser.UnionUserData(string key, object value);

/// <summary> Multiple union of a given lists with a list-valued properties at once </summary>
/// <param name="values"> An associative array of property names and values </param>
DevToDev.Analytics.ActiveUser.UnionUserData(Dictionary<string, object> values);

Removing the custom property

Removes a property or a list of properties and their values from the current user's profile.

/// <summary> Removes property from user data. </summary>
/// <example> Usage:
/// <code>
///     DevToDev.Analytics.ActiveUser.UnsetUserData("Hair color");
/// </code>
/// </example>
/// <param name="key"> The name of the property </param>
DevToDev.Analytics.ActiveUser.UnsetUserData(string key);

/// <summary> Removes multiple properties from user data at once. </summary>
/// <example> Usage:
/// <code>
///     List<string> unsetData = new List<string>();
///     unsetData.add("Hair color");
///     unsetData.add("Last payment");
///     DevToDev.Analytics.ActiveUser.UnsetUserData(unsetData);
/// </code>
/// </example>
/// <param name="keys"> An array of property names </param>
DevToDev.Analytics.ActiveUser.UnsetUserData(List<string> keys);

Clearing of all custom properties

/// <summary> Removes all user's custom personal data from devtodev data base.</summary>
Basic methods
Secondary methods