> For the complete documentation index, see [llms.txt](https://docs.dfinery.ai/developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dfinery.ai/developer-guide/en/undefined/identity-scenario.md).

# Unified ID Linkage Scenario

This document explains a hypothetical scenario as an example to help you understand the configuration of user information and terminal connection due to user identification information settings.

## First time installing the app

To initialize the SDK, users must follow the steps outlined in the integration guide for each platform.

## User Login

This section shows the process of transitioning from [an anonymous user profile](https://docs.dfinery.ai/developer-guide/common/identity-scenario#anonymous-user) state to [an identified user profile.](https://docs.dfinery.ai/developer-guide/common/identity-scenario#identified-user)

### 1. Set user identification information

Before recording a login event, `EXTERNAL_ID`set the user identification information to a value that distinguishes the user. Through this process, the user is converted from an anonymous user profile to an identified user profile, and a unified ID is generated so that the user can be identified through the unified ID on any platform.

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.setIdentity(DFIdentity.EXTERNAL_ID, "A")
//You can increase the accuracy of user identification by setting additional identification information.
DfineryProperties.setIdentity(DFIdentity.EMAIL, "A@igaworks.com")
DfineryProperties.setIdentity(DFIdentity.PHONE_NO, "8201012345678")
...
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().setIdentity(key: DFIdentity.EXTERNAL_ID, value: "A")
//You can increase the accuracy of user identification by setting additional identification information.
Dfinery.shared().setIdentity(key: DFIdentity.EMAIL, value: "jimmy.kang@igaworks.com")
Dfinery.shared().setIdentity(key: DFIdentity.PHONE_NO, value: "821012345678")
...
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "A")
//You can increase the accuracy of user identification by setting additional identification information.
Dfinery.setIdentity(DFIdentity.EMAIL, "A@igaworks.com")
Dfinery.setIdentity(DFIdentity.PHONE_NO, "8201012345678")
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="sequenceDiagram
participant 익명유저
Note over 익명유저: EXTERNAL\_ID를 "A"로 설정
익명유저->>식별된유저A: 식별된 유저 A로 변경" %}

### 2. Setting up a user profile

If there is information required for the settings corresponding to the identified user A, it is reflected through the user profile settings.

{% hint style="success" %}
User profiles can reflect arbitrary key values ​​set by the user in the console.
{% endhint %}

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.setUserProfile(DFUserProfile.GENDER, DFGender.MALE)
DfineryProperties.setUserProfile(DFUserProfile.MEMBERSHIP, "VIP")
...
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().setUserProfile(key: DFUserProfile.GENDER, value: DFGENDER.MALE)
Dfinery.shared().setUserProfile(key: DFUserProfile.MEMBERSHIP, value: "VIP")
...
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.setUserProfile(DFUserProfile.GENDER, DFGender.MALE)
Dfinery.setUserProfile(DFUserProfile.MEMBERSHIP, "VIP")
...
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="classDiagram
class 식별된유저A
식별된유저A : gender("MALE")
식별된유저A : membership("VIP")" %}

### 3. Record login events

Logs login events.

{% tabs %}
{% tab title="Java" %}

```java
Dfinery.getInstance().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.logEvent(DFEvent.LOGIN)
```

{% endtab %}
{% endtabs %}

## User logout

This section shows the process of an identified user A logging out.

### 1. Record the logout event

Logs logout events.

{% tabs %}
{% tab title="Java" %}

```java
Dfinery.getInstance().logEvent(DFEvent.LOGOUT)
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().logEvent(DFEvent.LOGOUT)
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.logEvent(DFEvent.LOGOUT)
```

{% endtab %}
{% endtabs %}

### 2. Initialize user identification information (optional)

If you do not want actions to be targeted to identified user A after he or she logs out, `resetIdentity()`initialize the user identification information by calling the API.

{% hint style="warning" %}
Please be careful when making calls, as initializing user identification information will interrupt any ongoing event flow and disconnect the terminal from the user.

If you still call, please call the event you want to reflect before calling the API to reflect the collected events.
{% endhint %}

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.resetIdentity();
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().resetIdentity()
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.resetIdentity()
```

{% endtab %}
{% endtabs %}

## `EXTERNAL_ID`Login using existing

This section `EXTERNAL_ID`shows how a user who has previously set up unified identity information can log in again using the same values.

### 1. Set user identification information

If the entered `EXTERNAL_ID`value is the same as the existing one, the terminal will be reconnected with the previously created identified user A.

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.setIdentity(DFIdentity.EXTERNAL_ID, "A")
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().setIdentity(key: DFIdentity.EXTERNAL_ID, value: "A")
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "A")
```

{% endtab %}
{% endtabs %}

### 2. Record login events

The flow of events continues as before, with the event flow of identified user A continuing.

{% tabs %}
{% tab title="Java" %}

```java
Dfinery.getInstance().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.logEvent(DFEvent.LOGIN)
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="graph TB
subgraph 식별된유저A
A(Login)--> B(Logout) --> C(Login)
end" %}

## `EXTERNAL_ID`Log in using another

This section `EXTERNAL_ID`shows how a user who has set up unified identity information can log in using different values.

### 1. Set user identification information

If the entered `EXTERNAL_ID`value is different from the existing one, the SDK determines that the user is a different user and deletes all previously saved integrated ID information and sets a new one, and the terminal is connected to the identified user B.

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.setIdentity(DFIdentity.EXTERNAL_ID, "B")
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().setIdentity(key: DFIdentity.EXTERNAL_ID, value: "B")
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "B")
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="sequenceDiagram
participant 식별된유저A
Note over 식별된유저A: EXTERNAL\_ID를 "B"로 설정
Note over 식별된유저A,식별된유저B: A의 식별 정보 제거
식별된유저A->>식별된유저B: 식별된 유저 B로 변경" %}

### 2. Setting up a user profile

The user profile is reflected to the identified user B.

{% tabs %}
{% tab title="Java" %}

```java
DfineryProperties.setUserProfile(DFUserProfile.GENDER, DFGender.FEMALE)
DfineryProperties.setUserProfile(DFUserProfile.MEMBERSHIP, "VVIP")
...
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().setUserProfile(key: DFUserProfile.GENDER, value: DFGender.FEMALE)
Dfinery.shared().setUserProfile(key: DFUserProfile.MEMBERSHIP, value: "VVIP")
...
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.setUserProfile(DFUserProfile.GENDER, DFGender.FEMALE)
Dfinery.setUserProfile(DFUserProfile.MEMBERSHIP, "VVIP")
...
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="classDiagram
class 식별된유저A
식별된유저A : gender("MALE")
식별된유저A : membership("VIP")
class 식별된유저B
식별된유저B : gender("FEMALE")
식별된유저B : membership("VVIP")" %}

### 3. Record login events

The flow of events changes to the flow of events for the newly identified user B.

{% tabs %}
{% tab title="Java" %}

```java
Dfinery.getInstance().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Swift" %}

```swift
Dfinery.shared().logEvent(DFEvent.LOGIN)
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
Dfinery.logEvent(DFEvent.LOGIN)
```

{% endtab %}
{% endtabs %}

{% @mermaid/diagram content="graph TB
subgraph 식별된유저B
D(Login)
end
subgraph 식별된유저A
A(Login)--> B(Logout) --> C(Login)
end" %}

***

## Terminology

### Anonymous user profile <a href="#anonymous-user" id="anonymous-user"></a>

If you do not set up user identification information, the user will be treated as an anonymous user. For example, this could be a user who visited your website but did not register, or a user who downloaded your mobile app but did not create a profile.

When a user is initially recognized through the SDK, a unique identifier generated by the SDK is issued and an anonymous user profile is created.

### Identified user profiles <a href="#identified-user" id="identified-user"></a>

If you set a value for one of the identification information types below, `EXTERNAL_ID`you will be treated as an identified user in DFINERY, and you will be able to identify the same user profile on multiple devices. You can also set additional information such as user email and phone number for more specific user identification.
