# Standard attributes

Explore the predefined attributes available on every user profile.

Standard attributes are predefined properties available on every user profile. They cover personal details, contact information, behavioral signals, and computed metrics.

## Personally identifiable information

Some attributes may hold personally identifiable information, such as name, email, and phone. Because we put privacy first, the platform restricts how this kind of data can be accessed when the user has not been identified.

> **Question: Why are these attributes restricted for anonymous users?**
>
> This design decision exists because of the [right to erasure](https://gdpr-info.eu/art-17-gdpr/). If an [anonymous user](/explanation/user-profiles/introduction#identification) requests deletion of their personal data, there is no reliable way to associate that data with a specific individual. Letting these attributes be readable while the user is anonymous could create data the platform cannot confidently trace back or remove on request.

Still, you can still set these attributes for an anonymous user. The captured values are kept until either of the following happens:

- The user identifies themselves, and the values are migrated to their identified profile and become available for audiences and personalization.
- The session ends without the user identifying themselves, and the captured values are discarded.

> **Check your local privacy laws**
>
> The platform acts as a data processor, handling this information on your behalf. Collecting user consent and complying with the privacy laws that apply to your business and your users' jurisdictions is your responsibility as the data controller.

## Implementation

Here is an example of how to set a standard attribute:

**JavaScript**

```javascript
import croct from '@croct/plug';

await croct.user.edit()
.set('firstName', "John")
.save();
```

**HTML**

```html
<!DOCTYPE html>
<html>
<head>
  <title>My awesome application</title>
  <script src="https://cdn.croct.io/js/v1/lib/plug.js"></script>
  <script>croct.plug({appId: 'APPLICATION_ID'});</script>
</head>
<body>
  <script>
    const update = () => croct.user.edit()
      .set('firstName', "John")
      .save();
  </script>
  <button onclick="update()">Update</button>
</body>
</html>
```

**React — JavaScript**

```jsx
import {useCroct} from '@croct/plug-react';

export function Example() {
const croct = useCroct();

const update = () => croct.user.edit()
  .set('firstName', "John")
  .save();

return (<button onClick={update}>Update</button>);
}
```

**React — TypeScript**

```typescript
import {useCroct} from '@croct/plug-react';
import type {ReactElement} from 'react';

export function Example(): ReactElement {
const croct = useCroct();

const update = () => croct.user.edit()
  .set('firstName', "John")
  .save();

return (<button onClick={update}>Update</button>);
}
```

**Next — JavaScript**

```jsx
import {useCroct} from '@croct/plug-next';

export function Example() {
const croct = useCroct();

const update = () => croct.user.edit()
  .set('firstName', "John")
  .save();

return (<button onClick={update}>Update</button>);
}
```

**Next — TypeScript**

```tsx
import {useCroct} from '@croct/plug-next';
import type {ReactElement} from 'react';

export function Example(): ReactElement {
const croct = useCroct();

const update = () => croct.user.edit()
  .set('firstName', "John")
  .save();

return (<button onClick={update}>Update</button>);
}
```

**Vue — JavaScript**

```vue
<script setup>
import {useCroct} from '@croct/plug-vue'

const croct = useCroct()

const update = () => croct.user.edit()
.set('firstName', "John")
.save()
</script>

<template>
  <button @click="update">Update</button>
</template>
```

**Vue — TypeScript**

```vue
<script setup lang="ts">
import {useCroct} from '@croct/plug-vue'

const croct = useCroct()

const update = (): void => {
croct.user.edit()
  .set('firstName', "John")
  .save()
}
</script>

<template>
  <button @click="update">Update</button>
</template>
```

**Nuxt — JavaScript**

```vue
<script setup>
const croct = useCroct()

const update = () => croct.user.edit()
.set('firstName', "John")
.save()
</script>

<template>
  <button @click="update">Update</button>
</template>
```

**Nuxt — TypeScript**

```vue
<script setup lang="ts">
const croct = useCroct()

const update = (): void => {
croct.user.edit()
  .set('firstName', "John")
  .save()
}
</script>

<template>
  <button @click="update">Update</button>
</template>
```

## Attributes

- `firstName`: `string|null` (optional)

  The user's first name. For example, "John".

  The value must be between 1 and 50 characters long.

  *Personally identifiable information.*

- `lastName`: `string|null` (optional)

  The user's last name. For example, "Doe".

  The value must be between 1 and 50 characters long.

  *Personally identifiable information.*

- `birthDate`: `string|null` (optional)

  The user's birth date. For example, "1990-01-01".

  The value must be a valid [ISO 8601 date](https://en.wikipedia.org/wiki/ISO_8601#calendar_dates) in the form `YYYY-MM-DD`.

  *Personally identifiable information.*

- `gender`: `string`

  The gender of the user.

  These are the possible values and what they represent:

  | Value     | Description                     |
  | --------- | ------------------------------- |
  | `male`    | Male gender.                    |
  | `female`  | Female gender.                  |
  | `neutral` | Neither male nor female gender. |
  | `unknown` | An unspecified gender.          |

  *Personally identifiable information.*

- `email`: `string|null` (optional)

  The user's email address.

  The value must be between 1 and 254 characters long.

  *Personally identifiable information.*

- `alternateEmail`: `string|null` (optional)

  The user's alternate email address, such as a work email address or secondary email address.

  The value must be between 1 and 254 characters long.

  *Personally identifiable information.*

- `phone`: `string|null` (optional)

  The user's phone number.

  The value must be between 1 and 30 characters long.

  *Personally identifiable information.*

- `alternatePhone`: `string|null` (optional)

  The user's alternate phone number, such as a work phone number or a secondary phone number.

  The value must be between 1 and 30 characters long.

  *Personally identifiable information.*

- `address`: `object|null` (optional)

  The user's address.

  - `street`: `string`

    The address' street.

    The value must be between 1 and 100 characters long.

  - `district`: `string`

    The address' district.

    The value must be between 1 and 100 characters long.

  - `city`: `string`

    The address' city.

    The value must be between 1 and 100 characters long.

  - `region`: `string`

    The address' region.

    The value must be between 1 and 100 characters long.

  - `country`: `string`

    The address' country.

    The value must be between 1 and 100 characters long.

  - `postalCode`: `string`

    The address' postal code.

    The value must be between 1 and 20 characters long.

  *Personally identifiable information.*

- `avatar`: `string|null` (optional)

  The URL of the user's avatar image.

  *Personally identifiable information.*

- `company`: `string|null` (optional)

  The company the user works for.

  The value must be between 1 and 200 characters long.

  *Personally identifiable information.*

- `companyUrl`: `string|null` (optional)

  The URL of the company the user works for.

  *Personally identifiable information.*

- `jobTitle`: `string|null` (optional)

  The job title of the user.

  The value must be between 1 and 50 characters long.

  *Personally identifiable information.*

- `interests`: `Array<string>`

  The user's demonstrated interests, such as "ab testing", "analytics", "data science", etc.

  The value must be a list of up to 30 strings, each between 1 and 30 characters long.

- `activities`: `Array<string>`

  The user's performed activities, like "sign up", "purchase", "upgrade", etc.

  The value must be a list of up to 30 strings, each between 1 and 30 characters long.

- `stats`: `object`

  Computed metrics about the user's activity.

  The platform updates these values automatically based on tracked events.

  - `sessions`: `integer`

    The total number of sessions across all applications.

    The platform automatically increments this counter every time the user starts a new session.

  - `orders`: `integer`

    The total number of orders placed across all sessions.

    The platform automatically increments this counter every time an [order placed](/reference/event/types/ecommerce/order-placed) event is tracked.

## Explore

- [Custom attributes](/reference/user/custom-attributes): Define additional attributes specific to your business.
- [Audiences](/explanation/audience): Understand how to deliver content to specific groups of users.
