Skip to main content
User types define the structure of user information attached to events.

User Interface

From packages/core/src/types-hoist/user.ts:

Fields

id

string | number
Unique identifier for the user. Can be a string or number.

email

string
User’s email address.

username

string
User’s username or display name.

ip_address

string | null
User’s IP address. Use '{{auto}}' to automatically capture from request.

geo

GeoLocation
Geographic location information.

Custom Fields

The User interface allows arbitrary custom fields:

GeoLocation Interface

Fields

string
Two-letter ISO country code.
string
State, province, or region name.
string
City name.

Setting User Context

Using Scope

With Custom Fields

Clearing User

Per-Event User

Privacy Considerations

Automatic IP Capture

Disable IP Capture

Hashing Emails

Complete Examples

Basic User

User with Geo Location

User with Subscription Info

User in Express Middleware

User with Authentication Context

Best Practices

1. Always Set User ID

2. Clear User on Logout

3. Don’t Include Sensitive Data

4. Use Consistent ID Format

5. Include User Segments