> ## 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

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 <a href="https://console.argyle.com/dashboard" target="_blank">Console's Dashboard</a> or contact your customer success manager.
</Note>

## Callback format

Add the line below to your Link initialization:

<Tabs>
  <Tab title="Web">
    ```js theme={}
    onUIEvent: (payload) => console.log('onUIEvent', payload),
    ```
  </Tab>

  <Tab title="iOS">
    ```swift theme={}
    config.onUIEvent = { data in
        print("Result: onUIEvent \(data)")
    }
    ```
  </Tab>

  <Tab title="Android">
    ```kotlin theme={}
    config.onUIEvent = { data ->
        Log.d("Result", "onUIEvent $data")
    }
    ```
  </Tab>

  <Tab title="React Native">
    ```js theme={}
    onUIEvent: (payload) => console.log('onUIEvent', payload);
    ```
  </Tab>

  <Tab title="Flutter">
    ```dart theme={}
    onUIEvent: (payload) => debugPrint('onUIEvent');
    ```
  </Tab>
</Tabs>

## Callback payload

The `onUIEvent` callback returns:

1. The `name` of the [UI-related Event](/link/reference/tracking#events) that triggered the callback.
2. A `properties` object, which can include:
   * `deepLink` (always) — Whether the user was [directly connected](/workflows/account-connections#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](/link/reference/tracking#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

<div className="argyle-divider" />

### Intro screen

<Frame>
  <img src="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" alt="Intro screen in Link." width="1400" height="900" data-path="images/argyle-guides/link/analytics/1-intro-screen.png" />
</Frame>

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

### Search screen

<Frame>
  <img src="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" alt="Search screen in Link." width="2100" height="1350" data-path="images/argyle-guides/link/analytics/2-search-screen.png" />
</Frame>

| 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`

### Login screen

<Frame>
  <img src="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" alt="Login screen in Link." width="2116" height="1366" data-path="images/argyle-guides/link/analytics/3-login-screen.png" />
</Frame>

| 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](/api-reference/account-connection-errors) 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

<Frame>
  <img src="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" alt="MFA screen in Link." width="2100" height="1350" data-path="images/argyle-guides/link/analytics/4-MFA-screen.png" />
</Frame>

| Event Name     | Event Description                                                                                                         | Event Specific Properties |
| -------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `mfa - opened` | The user was routed through a [multi-factor authentication (MFA) process](/workflows/account-connections#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

<Frame>
  <img src="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" alt="Success screen in Link." width="2104" height="1359" data-path="images/argyle-guides/link/analytics/5-success-screen.png" />
</Frame>

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

### Account status screen

<Frame>
  <img src="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" alt="Account status screen in Link." width="1790" height="1149" data-path="images/argyle-guides/link/analytics/6-account-status.png" />
</Frame>

| 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

<Frame>
  <img src="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" alt="Account error screen in Link." width="2100" height="1350" data-path="images/argyle-guides/link/analytics/10-account-error.png" />
</Frame>

| 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](/api-reference/accounts#object).
* `connectionErrorCode` — The [account connection error](/api-reference/account-connection-errors) that occurred.

<Note>
  `connectionErrorCode` is only returned when `connectionStatus` = `error`
</Note>

### Link error screen

<Frame>
  <img src="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" alt="Link error screen in Link." width="2100" height="1350" data-path="images/argyle-guides/link/analytics/11-link-error.png" />
</Frame>

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

**Property definitions:**

* `errorType` — The [Link error](/link/reference/error-codes) 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](/link/initialization), or when the [onCantFindItemClicked](/link/reference/callbacks#oncantfinditemclicked) callback is used, or any other event that causes Link to close.
</Note>
