User types

Learn about the user-related types available in CQL.

User types refer to data types representing personal information, such as user profiles, usage statistics, and other user traits.

This summary provides an overview of the user-related types:

TypeDescription
UserGeneral information about the user.
GenderThe enumeration of genders.
User statisticsAggregate statistics about the user.

User

The user type represents an individual, such as a customer, user, or anonymous visitor. It stores the profile, statistics, and other personal information.

The user profile has predefined properties that are common to all users. In addition, it can be extended with custom properties to store any additional information about the user, called custom attributes. These attributes are not listed below as they are not part of the type definition, but they can be accessed similarly to any other property.

For example, if you have a custom property called plan that stores the user's subscription plan, you can access it like this:

When accessing a property, if there is a custom attribute and a predefined attribute with the same name, the custom attribute takes precedence. However, it does not overwrite the predefined attribute — it simply hides it. Removing the custom attribute would make the predefined attribute visible again.

Properties

These are the predefined properties of the user profile:

id(optional)string

The user's unique identifier provided by the application, such as a UUID or a username.

name(optional)string

The name of the user as a combination of their first and last name, separated by a space. For instance, "John Doe".

This property is virtual, meaning it is not stored in the user profile. Instead, it is derived from the first and last name.

firstName(optional)string

The first name of the user. For example, "John".

lastName(optional)string

The last name of the user. For example, "Doe".

age(optional)integer

The age of the user. For example, 30.

birthDate(optional)Date

The birth date of the user. For example, 1990-01-01.

This property is virtual, meaning it is not stored in the user profile. Instead, it is derived from the age.

gender(optional)Gender

The gender of the user.

email(optional)string

The email address of the user. For example, "john@example.com".

alternateEmail(optional)string

The alternate email address of the user, such as a work email address or a secondary email address.

phone(optional)string

The phone number of the user. For example, "+1 555 555 5555".

alternatePhone(optional)string

The alternate phone number of the user, such as a work phone number or a secondary phone number.

addressAddress

The address of the user.

avatar(optional)URI

The URL of the user's avatar image.

company(optional)string

The company the user works for.

companyUrl(optional)URI

The URL of the company the user works for.

jobTitle(optional)string

The job title of the user.

interestsset<string>

The set of interests the user demonstrates, with no duplicates. For example, "ab testing", "analytics", "data science", etc.

activitiesset<string>

The set of activities the user performs, with no duplicates. For example, "ab testing", "analytics", "data science", etc.

statsUserStatistics

The aggregate statistics about the user.

<attribute>(optional)primitive|collection<primitive>

A custom attribute, where /*<attribute>*/ is the name of the attribute.

Gender

This type is an enumeration that indicates the gender of a user.

These are the possible values and what they represent:

ValueDescription
maleMale gender.
femaleFemale gender.
neutralNeither male nor female gender.
unknownAn unspecified gender.

User statistics

The user-statistics type represents the aggregate statistics and numbers related to a user's behavior and activity across sessions.

Properties

These are the available properties:

sessionsinteger

The total number of sessions across all applications. It is incremented every time the user visits the application.

ordersinteger

The total number of orders placed across all sessions. It is incremented every time the user places an order.