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

# Tracking

> Track user interaction events from embedded Link.

Capture how users interact with Link.

## Overview

You can track user behavior in Link by including the `onUIEvent` callback in your Link initialization.

The `onUIEvent` callback is triggered for specific UI events in Link, and although optional, including this callback can help with troubleshooting as well as optimizing conversion rates.

> [!NOTE]
>
> Callbacks are not designed to be a primary source of analytics information. For detailed metrics on step-by-step conversion success rates, visit the **Conversion** area of [Console's Dashboard](https://console.argyle.com/dashboard) or contact your customer success manager.

## Callback format

Add the line below to your Link initialization:

> [tab] Web
>
> ```js theme={}
> onUIEvent: (payload) => console.log('onUIEvent', payload),
> ```

> [tab] iOS
>
> ```swift theme={}
> config.onUIEvent = { data in
>     print("Result: onUIEvent \(data)")
> }
> ```

> [tab] Android
>
> ```kotlin theme={}
> config.onUIEvent = { data ->
>     Log.d("Result", "onUIEvent $data")
> }
> ```

> [tab] React Native
>
> ```js theme={}
> onUIEvent: (payload) => console.log('onUIEvent', payload);
> ```

> [tab] Flutter
>
> ```dart theme={}
> onUIEvent: (payload) => debugPrint('onUIEvent');
> ```

## Callback payload

The `onUIEvent` callback returns:

1. The `name` of the [UI-related Event](https://docs.argyle.com/link/reference/tracking.md#events) that triggered the callback.
2. A `properties` object, which can include:
   * `deepLink` (always) — Whether the user was [directly connected](https://docs.argyle.com/workflows/account-connections.md#direct-login) to the Item.
   * `userId` (always) — ID of the user.
   * `accountId` (conditional) — ID of the user's account.
   * `itemId` (conditional) — ID of the relevant Item.
   * Event-specific properties (conditional) — See [Events](https://docs.argyle.com/link/reference/tracking.md#events) below.

#### Example:

```json theme={}
UIEvent (
    "name": "mfa - opened",
    "properties": {
        "deepLink": false,
        "userId": "019ac324-91b5-2e5b-dc96-c931e25da1e2",
        "itemId": "item_123456789",
        "type": "Login",
        "mfaType": "sms_code"
    }
)
```

## Events

### Intro screen

![Intro screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/1-intro-screen.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=3a25a8612a9820c7261eb238d32def0b)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `intro - opened` | The user opened the intro screen. | none |

### Search screen

![Search screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/2-search-screen.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=1e4bb8b3317fc3a242c8faaf630ed961)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `search - opened` | The user opened the search screen. | none |
| `search - term updated` | The user entered a search term. | `term`, `tab` |
| `search - link item selected` | The user selected an Item from the search screen. | `term`, `tab` |

**Property definitions:**

* `term` — The text entered in the search field.
* `tab` — The tab that was open when the user entered a search term or selected an Item. Ignored for empty (or deleted) search terms. Possible values: `Popular`, `Payroll providers`, `Employers`

### User profile screen

![Your connections screen in Link.](https://mintcdn.com/argyle/zs6lb-w1jQV9DVbr/images/workflows/reconnecting-accounts/8-reconnecting-accounts.png?fit=max\&auto=format\&n=zs6lb-w1jQV9DVbr\&q=85\&s=64ab75eeece21ea24fee266a9227f692)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `user profile - opened` | The user opened the user profile (Your connections) screen. | none |

### Login screen

![Login screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/3-login-screen.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=22a866e61fab748d61da3553ab4a8dea)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `login - opened` | The user opened the login screen or was returned to the login screen after a connection error. | `errorCode`, `errorMessage` |
| `login - form submitted` | The user submitted login credentials. | none |
| `login - login help clicked` | The user selected "Login help". | none |

**Property definitions:**

* `errorCode` — The [account connection error](https://docs.argyle.com/api-reference/account-connection-errors.md) relevant to the login screen that occurred. Possible values: `auth_required`, `connection_unavailable`, `expired_credentials`, `invalid_auth`, `invalid_credentials`, `mfa_cancelled_by_the_user`
* `errorMessage` — The account connection error message shown to the user.

### MFA screen

![MFA screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/4-MFA-screen.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=34f6d7702abfa4171f5112bbf8415ee3)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `mfa - opened` | The user was routed through a [multi-factor authentication (MFA) process](https://docs.argyle.com/workflows/account-connections.md#completing-mfa). | `type`, `mfaType` |

**Property definitions:**

* `type` — Whether MFA occurred during login. Possible value: `Login`
* `mfaType` — The type of MFA. Possible values: `sms_code`, `email_code`, `secret_question`, `email_link_confirmation`, `otp_code`, `email_message_confirmation`

### Success screen

![Success screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/5-success-screen.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=dbd9a02a9e8c25e814639a4f09edabb4)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `success - opened` | The user entered the success screen after a successful account connection. | none |

### Account status screen

![Account status screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/6-account-status.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=c3da39cd32ad8027bad82a7bffee5c11)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `account status - opened` | The user opened the account status screen. | none |
| `account status - disconnected` | The user revoked access to an account. | none |

### Account error screen

![Account error screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/10-account-error.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=8ec21debe76d11df07bca65b956d2786)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `account error - opened` | The user encountered an error while connecting an account. | `connectionStatus`, `connectionErrorCode` |

**Property definitions:**

* `connectionStatus` — The `connection.status` of the [Account](https://docs.argyle.com/api-reference/accounts.md#object).
* `connectionErrorCode` — The [account connection error](https://docs.argyle.com/api-reference/account-connection-errors.md) that occurred.

> [!NOTE]
>
> `connectionErrorCode` is only returned when `connectionStatus` = `error`

### Link error screen

![Link error screen in Link.](https://mintcdn.com/argyle/0Z2zBY-iD5Q5BvPN/images/argyle-guides/link/analytics/11-link-error.png?fit=max\&auto=format\&n=0Z2zBY-iD5Q5BvPN\&q=85\&s=06f6f6ccfef1e9dbf144a86910ab23d5)

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `error - opened` | The user encountered an error while opening Link. | `errorType` |

**Property definitions:**

* `errorType` — The [Link error](https://docs.argyle.com/link/reference/error-codes.md) that occurred.

### Link closed

Occurs when the user closes Link from any screen.

| Event Name | Event Description | Event Specific Properties |
| - | - | - |
| `link closed` | The user closed Link. | `closeMethod ` |

**Property definitions:**

* `closeMethod` — How Link was closed.

**Possible values:**

> [!NOTE]
>
> * `footer_button` — Link was closed by the user selecting the `Done` (re-nameable) button on a final screen.
>   * `x` — Link was closed by the user selecting `[X]` in the upper-left of the screen.
>   * `null` — Link was closed programmatically via an [Argyle SDK](https://docs.argyle.com/link/initialization.md), or when the [onCantFindItemClicked](https://docs.argyle.com/link/reference/callbacks.md#oncantfinditemclicked) callback is used, or any other event that causes Link to close.
