Skip to main content

Integrate SDK

SDK Version Selection

Choose your SDK version below:

  • Apptrove SDK → Recommended for all projects (Latest: v2.x.x)
  • Trackier SDK → Will be deprecated in August 2026 (v1.x.xx)

Use the tabs below for SDK-specific initialization snippets.

SDK-Specific Quick Initialization

import { AppTroveConfig, AppTroveSDK } from 'apptrove-expo-sdk';

const config = new AppTroveConfig('YOUR_SDK_KEY', AppTroveConfig.EnvironmentDevelopment);
config.setRegion(AppTroveConfig.IN); // or AppTroveConfig.GLOBAL
AppTroveSDK.initialize(config);

This guide provides step-by-step instructions to initialize the Apptrove Expo SDK in your Expo application. It covers retrieving your SDK key, setting up the SDK configuration, and configuring the SDK for different environments.


Initialization

Step 1: Retrieve Your SDK Key

  1. Log in to your Apptrove Panel
  2. Select your application
  3. Navigate to SDK Integration in the dashboard
  4. Copy the SDK Key displayed


Step 2: Initialize the SDK

We recommend initializing the SDK inside your app's main component or a dedicated initialization file. This ensures proper initialization in all scenarios, including deep linking.

2.1 Import the SDK

Add the following import statement at the top of your main application file (typically App.tsx or App.js):

import { AppTroveConfig, AppTroveSDK } from 'apptrove-expo-sdk';

2.2 Initialize the Apptrove SDK

Add the initialization code in your main application component's useEffect hook:

import { useEffect } from 'react';
import { AppTroveConfig, AppTroveSDK } from 'apptrove-expo-sdk';

export default function App() {
useEffect(() => {
const TR_SDK_KEY = "XXXXXXX-XXXX-XXXX-80e3-5938fadff"; // Your SDK key

const appTroveConfig = new AppTroveConfig(
TR_SDK_KEY, // Your Apptrove SDK key
AppTroveConfig.EnvironmentDevelopment // Environment: "development", "testing", or "production"
);

// Set region for better performance and compliance
appTroveConfig.setRegion(AppTroveConfig.IN); // For India region
// OR
// appTroveConfig.setRegion(AppTroveConfig.GLOBAL); // For global region

AppTroveSDK.initialize(appTroveConfig);
}, []);

return (
// Your app content
);
}

2.3 Initialize with Apple Ads Token (iOS)

For enhanced tracking on iOS, you can include Apple Ads token initialization:

import { useEffect } from 'react';
import { AppTroveConfig, AppTroveSDK } from 'apptrove-expo-sdk';
import { getAttributionToken } from 'react-native-attribution-token';

export default function App() {
useEffect(() => {
const initializeSDK = async () => {
const TR_SDK_KEY = "XXXXXXX-XXXX-XXXX-80e3-5938fadff"; // Your SDK key

// Get Apple Ads token before initializing SDK
try {
const appleAdsToken = await getAttributionToken();
if (appleAdsToken) {
AppTroveSDK.updateAppleAdsToken(appleAdsToken);
}
} catch (error) {
console.log('Error getting Apple Ads token:', error);
}

const appTroveConfig = new AppTroveConfig(
TR_SDK_KEY,
AppTroveConfig.EnvironmentDevelopment
);

appTroveConfig.setRegion(AppTroveConfig.IN);
AppTroveSDK.initialize(appTroveConfig);
};

initializeSDK();
}, []);

return (
// Your app content
);
}
note

To use Apple Ads token functionality, first install the react-native-attribution-token library:

npm install react-native-attribution-token
important

Using the wrong SDK key will impact all traffic sent from the SDK and cause attribution/reporting issues.


Step 3: Configure for Production

When ready to release your app:

  1. Change the environment parameter to TrackierConfig.EnvironmentProduction
  2. Update your log level as needed

Example for production:

const appTroveConfig = new AppTroveConfig(TR_SDK_KEY, AppTroveConfig.EnvironmentProduction);

Environment Configuration

Depending on whether you build your app for testing or for production, you must set the environment with one of these values:

AppTroveConfig.EnvironmentTesting    // For testing environment
AppTroveConfig.EnvironmentDevelopment // For development environment
AppTroveConfig.EnvironmentProduction // For production environment

Next Steps

After completing the initialization:

  1. Verify your integration by checking for incoming events in the Apptrove Panel
  2. Implement event tracking as needed (refer to the Event Tracking Guide)
  3. For assistance, contact Apptrove support at support@apptrove.com