Skip to main content

Integrate SDK

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 Trackier 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 { TrackierConfig, TrackierSDK } from 'trackier-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 { TrackierConfig, TrackierSDK } from 'trackier-expo-sdk';

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

const trackierConfig = new TrackierConfig(
TR_SDK_KEY, // Your AppTrove SDK key
TrackierConfig.EnvironmentDevelopment // Environment: "development", "testing", or "production"
);

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

TrackierSDK.initialize(trackierConfig);
}, []);

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 { TrackierConfig, TrackierSDK } from 'trackier-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) {
TrackierSDK.updateAppleAdsToken(appleAdsToken);
}
} catch (error) {
console.log('Error getting Apple Ads token:', error);
}

const trackierConfig = new TrackierConfig(
TR_SDK_KEY,
TrackierConfig.EnvironmentDevelopment
);

trackierConfig.setRegion(TrackierConfig.IN);
TrackierSDK.initialize(trackierConfig);
};

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 trackierConfig = new TrackierConfig(TR_SDK_KEY, TrackierConfig.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:

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

Next Steps

After completing the initialization:

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