# Identity and tags

> Log a person in with your own user id, log them out, and write tags.

URL: https://docs.xulo.io/ios/identity-and-tags
iOS SDK version: 0.1.4

## Log in

```swift
await Xulo.login(externalId: "USER_ID")
```

`login` takes the id your app already uses, as text. All installs that log in with the same External ID belong to one person. The first login keeps the tags the anonymous person already had.

A blank value does not log the device out.

## Log out

```swift
await Xulo.logout()
```

`logout` removes the External ID from this install and starts a new anonymous person on it. The Subscription ID and the push token stay. The person's other installs are not touched.

## Read the ids

```swift
let install = Xulo.subscriptionId // this install
let person = Xulo.xuloId          // this person, once registered
```

`Xulo.subscriptionId` stays the same when the token refreshes and when the person logs out. See [People and devices](https://docs.xulo.io/concepts/people-and-devices).

## Write tags

```swift
Xulo.setTags(["plan": "pro"])
Xulo.addTag(key: "summary", value: "1")
```

- `setTags` replaces the tags this install sends.
- `addTag` writes one key and keeps the others.
- `"0"` is a value, not a delete.
- Keys that arrive overwrite the stored value. Keys that do not arrive stay.
- An install sends at most 30 tags.

Tags belong to the person, so every install of that person reads them. See [Tags](https://docs.xulo.io/concepts/tags).
