> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trypillow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# User identification

> Identify users and set properties for targeting on iOS

Identifying users lets you connect SDK sessions to real users in your system and target specific segments for studies.

For the concepts behind this, see [About identification](/sdk/concepts/identification).

## Set an external ID

Link the SDK session to a user in your system. This is typically the user ID from your database or auth system.

```swift theme={"theme":{"light":"github-light","dark":"github-dark"}}
PillowSDK.shared.setExternalId(externalId: "user_123")
```

Call this after login or whenever the user's identity is known.

<Note>
  The external ID must not be blank.
</Note>

## Set user properties

Attach metadata to the user for targeting and segmentation.

### String

```swift theme={"theme":{"light":"github-light","dark":"github-dark"}}
PillowSDK.shared.setUserProperty(key: "plan", stringValue: "pro")
PillowSDK.shared.setUserProperty(key: "role", stringValue: "engineering")
PillowSDK.shared.setUserProperty(key: "locale", stringValue: "en-US")
```

### Boolean

```swift theme={"theme":{"light":"github-light","dark":"github-dark"}}
PillowSDK.shared.setUserProperty(key: "email_verified", booleanValue: true)
PillowSDK.shared.setUserProperty(key: "beta_user", booleanValue: false)
```

### Numeric

```swift theme={"theme":{"light":"github-light","dark":"github-dark"}}
PillowSDK.shared.setUserProperty(key: "login_count", intValue: 7)
PillowSDK.shared.setUserProperty(key: "lifetime_value", doubleValue: 49.5)
```

## Clear properties

```swift theme={"theme":{"light":"github-light","dark":"github-dark"}}
// Remove a single property
PillowSDK.shared.clearUserProperty(key: "plan")

// Remove all properties
PillowSDK.shared.clearAllProperties()
```

## When to identify

| Event                          | Action                                             |
| ------------------------------ | -------------------------------------------------- |
| User logs in                   | Call `setExternalId()` and set known properties    |
| User updates profile           | Call `setUserProperty()` with new values           |
| User logs out                  | Call `reset()` to clear identity and start fresh   |
| App launch (already logged in) | Call `setExternalId()` again; the SDK deduplicates |
