|
| 1 | +--- |
| 2 | +title: Custom Traits |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +Custom traits are user or account traits collected from the Identify calls you send to Segment. For example, these could be demographics like `age` or `gender`, account-specific like `plan`, or even things like whether a user has seen a particular A/B test variation. From your sources, send custom traits as pieces of information that you know about a user in an Identify call. |
| 7 | + |
| 8 | +As opposed to [computed traits](/docs/unify/traits/computed-traits/) which are computed from your source or warehouse data, custom traits are created from source events you pass into Segment. |
| 9 | + |
| 10 | +## Using custom traits |
| 11 | + |
| 12 | +Here's the payload of a typical Identify call with custom traits (with most [common fields](/docs/connections/spec/common/) removed): |
| 13 | + |
| 14 | +```json |
| 15 | +{ |
| 16 | + "type": "identify", |
| 17 | + "traits": { |
| 18 | + "name": "John Smith", |
| 19 | + |
| 20 | + "plan": "premium", |
| 21 | + "logins": 5 |
| 22 | + }, |
| 23 | + "userId": "97980cfea0067" |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +And here's the corresponding JavaScript event that would generate the above payload: |
| 28 | + |
| 29 | +```js |
| 30 | +analytics.identify("97980cfea0067", { |
| 31 | + name: "John Smith", |
| 32 | + |
| 33 | + plan: "premium", |
| 34 | + logins: 5 |
| 35 | +}); |
| 36 | +``` |
| 37 | + |
| 38 | +> success "" |
| 39 | +> Any source event where there's a `traits` object and key value pairs generates custom traits. |
| 40 | +
|
| 41 | +Custom traits are mutable and update to the latest value seen by the user's Identify events. |
| 42 | + |
| 43 | +When an audience that previously generated Identify events is deleted, the data for the audience key is still attached to profiles that entered the audience and becomes visible in Segment as a custom trait. |
| 44 | + |
| 45 | +Use the Profile explorer (**Unify > Profile explorer**) to view custom traits attached to a profile. |
| 46 | + |
| 47 | + |
| 48 | +## Reserved custom traits |
| 49 | + |
| 50 | +Segment has reserved some custom traits that have semantic meanings for users, and will handle them in special ways. For example, Segment always expects `email` to be a string of the user's email address. Segment sends this on to destinations like _Mailchimp_ that require an email address for their tracking. |
| 51 | + |
| 52 | +You should **only use reserved custom traits for their intended meaning**. |
| 53 | + |
| 54 | +Reserved custom traits Segment has standardized: |
| 55 | + |
| 56 | +| **Trait** | **Type** | **Description** | |
| 57 | +|---------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 58 | +| `address` | Object | Street address of a user optionally containing: `city`, `country`, `postalCode`, `state`, or `street` | |
| 59 | +| `age` | Number | Age of a user | |
| 60 | +| `avatar` | String | URL to an avatar image for the user | |
| 61 | +| `birthday` | Date | User's birthday | |
| 62 | +| `company` | Object | Company the user represents, optionally containing: `name` (String), `id` (String or Number), `industry` (String), `employee_count` (Number) or `plan` (String) | |
| 63 | +| `createdAt` | Date | Date the user's account was first created. Segment recommends using [ISO-8601](http://en.wikipedia.org/wiki/ISO_8601){:target="_blank"} date strings. | |
| 64 | +| `description` | String | Description of the user | |
| 65 | +| `email` | String | Email address of a user | |
| 66 | +| `firstName` | String | First name of a user | |
| 67 | +| `gender` | String | Gender of a user | |
| 68 | +| `id` | String | Unique ID in your database for a user | |
| 69 | +| `lastName` | String | Last name of a user | |
| 70 | +| `name` | String | Full name of a user. If you only pass a first and last name Segment automatically fills in the full name for you. | |
| 71 | +| `phone` | String | Phone number of a user | |
| 72 | +| `title` | String | Title of a user, usually related to their position at a specific company. Example: "VP of Engineering" | |
| 73 | +| `username` | String | User's username. This should be unique to each user, like the usernames of Twitter or GitHub. | |
| 74 | +| `website` | String | Website of a user | |
| 75 | + |
| 76 | + |
| 77 | +To learn more about using an Identify call to tie custom traits to profiles, [visit Segment's Spec docs](/docs/connections/spec/identify/). |
| 78 | + |
| 79 | + |
0 commit comments