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

# Getting Started

Initialize the SDK, configure it for your ZMP site, and control tracking opt-in.

This guide covers SDK initialization in your `Application.onCreate()`, the full set of `ZTConfig` parameters, and how to defer data collection until the user consents.

## On this page

* [Initialize the SDK](#initialize-the-sdk)
* [ZTConfig parameters](#ztconfig-parameters)
* [Where to initialize](#where-to-initialize)
* [Setting the client secret](#setting-the-client-secret)
* [Tracking opt-in and opt-out](#tracking-opt-in-and-opt-out)

## Initialize the SDK

Initialize ZetaCore during your app's launch. Pass an `Application` context and a `ZTConfig` instance to `ZetaClient.initialize()`.

```kotlin
import net.zetaglobal.app.zetacore.ZTConfig
import net.zetaglobal.app.zetacore.ZetaClient
import net.zetaglobal.app.zetacore.network.ZTRegion
import net.zetaglobal.app.zetacore.common.ZTAppEnvironment

val config = ZTConfig(
    clientSecret = "your-client-secret",
    clientSiteId = "your-site-id",
    optIn = true,
    region = ZTRegion.US,
    appEnvironment = ZTAppEnvironment.PRODUCTION
)
ZetaClient.initialize(applicationContext, config)
```

```java
import net.zetaglobal.app.zetacore.ZTConfig;
import net.zetaglobal.app.zetacore.ZetaClient;
import net.zetaglobal.app.zetacore.network.ZTRegion;
import net.zetaglobal.app.zetacore.common.ZTAppEnvironment;

ZTConfig config = new ZTConfig(
    "your-client-secret",          // clientSecret
    "your-site-id",                // clientSiteId
    true,                          // optIn
    ZTRegion.US,                   // region
    ZTAppEnvironment.PRODUCTION    // appEnvironment
);
ZetaClient.INSTANCE.initialize(getApplicationContext(), config);
```

## `ZTConfig` parameters

| Parameter        | Required | Description                                                                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `clientSiteId`   | Required | Provided by the ZMP console after successful app registration.                                                               |
| `clientSecret`   | Optional | Provided by the ZMP console. Can be supplied at init time or later via `setClientSecret()`.                                  |
| `optIn`          | Required | Whether the SDK tracks events and sends data to the backend.                                                                 |
| `region`         | Required | Your ZMP region. Use a value from `ZTRegion` (`US` or `EU`). Region cannot be changed after your ZMP account is provisioned. |
| `appEnvironment` | Optional | `ZTAppEnvironment` value. Defaults to `PRODUCTION`.                                                                          |

> **Note:** Logging is configured separately via `ZTLogger.setLevel()` — it is not part of `ZTConfig`. See [Advanced / Logging](https://docs.zetaglobal.com/docs/android-sdk-logging).

## Where to initialize

Call `ZetaClient.initialize()` inside your `Application.onCreate()` or your launch Activity's `onCreate()`. Pass `applicationContext` — the SDK stores the application context internally and does not hold a reference to any `Activity`.

At initialization time, `clientSiteId`, `optIn`, and `region` are mandatory.

## Setting the client secret

If you did not pass a `clientSecret` at init time, set it later:

```kotlin
ZetaClient.setClientSecret(applicationContext, "your-secret")
```

```java
ZetaClient.INSTANCE.setClientSecret(getApplicationContext(), "your-secret");
```

> **Note:** Do not commit `clientSecret` to source control. Load it from a secure source at app launch.

## Tracking opt-in and opt-out

When your app does not require the SDK to track events and user properties, use the opt-out feature. Send the opt-out state either as part of `ZTConfig` during initialization, or by calling a dedicated opt-out method.

If your app uses the SDK-exposed opt-in / opt-out methods, pass the same status into `ZTConfig` on the next launch. Otherwise the `ZTConfig` value may overwrite the status set at runtime.

Once opted out, the SDK:

* Immediately stops all communication with the backend.
* Clears any data cached in the local database.
* Neither collects nor transmits any further data until the app opts back in.
* Treats a subsequent opt-in as a fresh launch.

### Opt out of tracking

You can disable tracking in two ways.

**1. Pass&#x20;**`optIn`**&#x20;as&#x20;**`false`**&#x20;during initialization.**

```kotlin
val config = ZTConfig(
    clientSiteId = "your-site-id",
    optIn = false,
    region = ZTRegion.US,
    appEnvironment = ZTAppEnvironment.PRODUCTION
)
ZetaClient.initialize(applicationContext, config)
```

```java
ZTConfig config = new ZTConfig(null, "your-site-id", false, ZTRegion.US, ZTAppEnvironment.PRODUCTION);
ZetaClient.INSTANCE.initialize(getApplicationContext(), config);
```

**2. Call the opt-out method at runtime.**

```kotlin
ZetaClient.optOutFromTracking(applicationContext)
```

```java
ZetaClient.INSTANCE.optOutFromTracking(getApplicationContext());
```

### Opt in to tracking

To start tracking again, either pass `optIn: true` during `ZetaClient.initialize()` or call:

```kotlin
ZetaClient.optInForTracking(uid = "user-id") // uid is optional
```

```java
ZetaClient.INSTANCE.optInForTracking("user-id"); // uid is optional, pass null for anonymous
```

The `uid` parameter is optional. If the app does not provide a user ID, the SDK treats the user as anonymous.

## Next

* Identify the user and track events: [Contact Management](https://docs.zetaglobal.com/docs/android-sdk-contact-management).
* Receive push notifications: [Push Notifications](https://docs.zetaglobal.com/docs/android-sdk-push-notifications).
* See also: [Data & Privacy](https://docs.zetaglobal.com/docs/android-sdk-data-and-privacy) for opt-in/out, data-rights, and privacy details.

## See also

* [Platform support](https://docs.zetaglobal.com/docs/sdk-platform-support) -- feature availability by platform and SDK version.

<br />