Getting started
Initialize the SDK, configure it for your ZMP site, and control tracking opt-in.
Once you have installed the package and configured your native projects, the next step is to initialize the SDK. This guide will walk you through JavaScript initialization, configuration options, native initialization, and tracking opt-in/opt-out.
On this page
- Initialize the SDK in JavaScript
- Understand ZTConfig options
- Handle client secret updates
- Initialize natively (Optional)
- Control tracking opt-in and opt-out
Initialize the SDK in JavaScript
Initialize the SDK once as early as possible in your application lifecycle, typically inside a useEffect hook in your root component (e.g., App.tsx).
import React, { useEffect } from 'react';
import ZetaClient, {
ZTRegion,
ZTAppEnvironment,
ZTLogger,
ZTLogLevel,
} from 'zetakit_reactnative';
const App = () => {
useEffect(() => {
// Optional: Enable logging before initialization to capture startup diagnostics
ZTLogger.setLogLevel(ZTLogLevel.DEBUG);
const config = {
clientSiteId: 'your-site-id',
clientSecret: 'your-secret',
region: ZTRegion.US,
appGroupId: 'group.com.example.app', // iOS only
optIn: true,
appEnvironment: ZTAppEnvironment.PRODUCTION,
};
ZetaClient.initialize(config, () => {
console.log('Zeta SDK is ready');
});
}, []);
return <YourAppRoot />;
};
export default App;During initialization, clientSiteId, optIn, and region are mandatory.
Understand ZTConfig options
The configuration object passed to ZetaClient.initialize() supports the following properties:
| Parameter | Required | Description |
|---|---|---|
clientSiteId | Required | The site identifier provided by the ZMP console after successful app registration. |
clientSecret | Optional | The authentication token provided by the ZMP console. Required for the SDK to communicate with ZMP. Can be supplied here or set later via setClientSecret(). |
region | Required | Your ZMP region. Use ZTRegion.US or ZTRegion.EU. Must match your ZMP account provisioning and cannot be changed afterward. |
optIn | Required | Whether the SDK is permitted to track events and send data to the backend. |
appGroupId | Optional (iOS only) | Used to track push notification delivery status on iOS. See the Push Notifications guide. |
appEnvironment | Optional | ZTAppEnvironment.PRODUCTION (default) or ZTAppEnvironment.SANDBOX. Selects the APNs environment the SDK expects on iOS. |
Handle client secret updates
If you do not have the client secret available at initialization time (for example, if you fetch it from a remote configuration service), you can supply it later:
ZetaClient.setClientSecret('your-secret');Security Note: Do not commit your
clientSecretdirectly to source control. Always load it from a secure source at app launch.
Initialize natively (Optional)
In some advanced scenarios, you may want the SDK to be ready before the React Native JavaScript bridge loads. You can choose to initialize the SDK from the native iOS or Android layer instead of JavaScript.
If you choose native initialization, do not call ZetaClient.initialize() from JavaScript. Initialize from one layer only.
For full native initialization guides and code examples, refer to the native documentation:
- iOS: Where to initialize — Configure initialization in your
AppDelegate.swift. - Android: Where to initialize — Configure initialization in your
Application.kt.
Control tracking opt-in and opt-out
The SDK supports user privacy preferences with explicit opt-in and opt-out controls.
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.
Opting out of tracking
You can opt out of tracking in two ways:
-
At Initialization: Pass
optIn: falsein yourZTConfigobject. -
At Runtime: Call the dedicated opt-out method:
ZetaClient.optOutFromTracking();
Opting in to tracking
To opt back in to tracking at runtime, call:
ZetaClient.optInForTracking('user-id');The uid parameter is optional. If your app does not provide a user ID, the SDK treats the user as anonymous.
Important: If your app uses runtime opt-in/opt-out methods, ensure you pass the same status into
ZTConfigon the next launch. Otherwise, the staticZTConfigvalue may overwrite the runtime preference.
Next step
Now that the SDK is initialized, continue to the next step of your journey:
- Contact Management — Identify users, update properties, and track custom events.
See also
- Platform support -- feature availability by platform and SDK version.

