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

# Integrate the Klaritics Android SDK in Your App

> Add the Klaritics Android SDK via Maven, initialize with app_id and server_host, and log app events, client events, and user identifiers.

The Klaritics Android SDK collects analytics from Android applications and sends them to your self-hosted Klaritics instance. This guide covers Gradle setup, initialization, event logging, and user identification.

## Installation

Add the Maven dependency to your module-level `build.gradle` or `build.gradle.kts`:

```kotlin theme={null}
implementation("com.deeptaai.klaritics:klaritics-android-sdk:x.x.x")
```

Replace `x.x.x` with the latest version number.

## Initialization

Initialize the SDK in your `Application` class or main entry point before logging any events:

```kotlin theme={null}
Klaritics.initialize(
    appId = "YOUR_APP_ID",
    serverHost = "https://YOUR_SERVER_HOST"
)
```

The SDK will not initialize until both `appId` and `serverHost` are provided.

## Logging events

Use `logAppEvent` for standard analytics events and `logClientEvent` for client-specific events.

<CodeGroup>
  ```kotlin App event theme={null}
  val additionalInfo = mapOf(
      "product_id" to "sku-123",
      "category" to "electronics"
  )
  Klaritics.logAppEvent("ProductClicked", additionalInfo)
  ```

  ```kotlin Client event theme={null}
  val clientInfo = mapOf(
      "source" to "soft_back"
  )
  Klaritics.logClientEvent("SoftBackPressed", clientInfo)
  ```
</CodeGroup>

## User identification

Link events to a known user with `setUserIdentifier`:

```kotlin theme={null}
Klaritics.setUserIdentifier("user@example.com")
```

Retrieve the SDK-generated device identifier:

```kotlin theme={null}
val deviceId = Klaritics.getDeviceId(applicationContext)
```

## Important naming note

The client-facing class is `Klaritics`. Do not use `KlariticsSDK`, `KlariticsCore`, or any other variant in your application code.
