Initialization
Choose your SDK version below:
- Apptrove SDK → Recommended for all projects (Latest: v2.x.x)
- Trackier SDK → Will be deprecated in August 2026 (Latest legacy: v1.x.xx)
Use the tabs below for SDK-specific snippets.
This section outlines the steps to initialize the Apptrove Cordova SDK in your Cordova or Ionic Native project. It covers retrieving your SDK key (app token) from the Apptrove Panel, configuring the SDK with the key and environment, and registering the provider for Ionic Native apps (if applicable).
Prerequisites
- Apptrove Cordova SDK installed in your project (Apptrove recommended)
- Apptrove account with access to the Apptrove Panel
- Cordova 9.0 or later
- For Ionic Native apps:
- Ionic CLI and Capacitor
@awesome-cordova-plugins/corepackage installed
- Basic knowledge of JavaScript, Angular (for Ionic Native), and Cordova development
Retrieve Your SDK Key
To initialize the Apptrove SDK, you need an SDK key (app token) from the Apptrove Panel.
Steps to Retrieve the SDK Key
- Log in to your Apptrove account.
- Select your application from the Dashboard.
- Navigate to SDK Integration via the left-side navigation menu.
- Copy the SDK Key to use as the
app_token.

Initialize the SDK
After installing the SDK, initialize it by configuring the SDK config object (AppTroveConfig for Apptrove, TrackierConfig for Trackier legacy) with your SDK key and environment in your Cordova or Ionic Native application. The SDK automatically registers with Cordova's deviceready, resume, and pause events.
Step 1: Configure the SDK for Cordova/Ionic Native
- Open your main application file (e.g.,
index.jsfor Cordova ortab1.page.tsfor Ionic Native). - Import the required Trackier modules and initialize the SDK after the
devicereadyevent (Cordova) or in thengOnInitlifecycle hook (Ionic Native). - Set the environment based on your deployment stage:
- Apptrove:
AppTroveEnvironment.Development,AppTroveEnvironment.Production,AppTroveEnvironment.Testing - Trackier legacy:
TrackierEnvironment.Development,TrackierEnvironment.Production,TrackierEnvironment.Testing
- Apptrove:
JavaScript Example (Ionic Native)
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
import { Component } from '@angular/core';
import { AppTroveCordovaPlugin, AppTroveConfig, AppTroveEnvironment } from 'com.apptrove.cordova_sdk/ionic-native/apptrove/ngx';
@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
constructor(private apptroveCordovaPlugin: AppTroveCordovaPlugin) {}
async ngOnInit() {
/* While Initializing the SDK, you need to pass the SDK key and environment.
* The first argument is the Apptrove SDK key.
* The second argument is the environment: "development", "production", or "testing". */
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var appTroveConfig = new AppTroveConfig(key, AppTroveEnvironment.Development);
// Set Android ID for enhanced tracking
appTroveConfig.setAndroidId("User Android Id "); // Optional And For Android Only
this.apptroveCordovaPlugin.initializeSDK(appTroveConfig);
}
}
import { Component } from '@angular/core';
import { TrackierCordovaPlugin, TrackierConfig, TrackierEnvironment } from '@awesome-cordova-plugins/trackier/ngx';
@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page {
constructor(private trackierCordovaPlugin: TrackierCordovaPlugin) {}
async ngOnInit() {
/* While Initializing the SDK, you need to pass the SDK key and environment.
* The first argument is the Apptrove SDK key.
* The second argument is the environment: "development", "production", or "testing". */
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
// Set Android ID for enhanced tracking
trackierConfig.setAndroidId("User Android Id "); // Optional And For Android Only
this.trackierCordovaPlugin.initializeSDK(trackierConfig);
}
}
JavaScript Example (Pure Cordova)
In pure Cordova projects, the plugin APIs are exposed as globals after deviceready (for example: AppTroveCordovaPlugin, AppTroveConfig, AppTroveEnvironment, TrackierCordovaPlugin, TrackierConfig, TrackierEnvironment).
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var appTroveConfig = new AppTroveConfig(key, AppTroveEnvironment.Development);
AppTroveCordovaPlugin.initializeSDK(appTroveConfig);
}
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
TrackierCordovaPlugin.initializeSDK(trackierConfig);
}
Step 2: Register the Provider for Ionic Native
For Ionic Native apps, register the provider that matches your SDK version (AppTroveCordovaPlugin for Apptrove, TrackierCordovaPlugin for Trackier legacy) in the app module to enable dependency injection.
- Open the
app.module.tsfile in your Ionic project. - Import the provider that matches your SDK version (
AppTroveCordovaPlugin/TrackierCordovaPlugin) and add it to theprovidersarray.
Example (app.module.ts)
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AppTroveCordovaPlugin } from 'com.apptrove.cordova_sdk/ionic-native/apptrove/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [AppTroveCordovaPlugin, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent]
})
export class AppModule {}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TrackierCordovaPlugin } from '@awesome-cordova-plugins/trackier/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [TrackierCordovaPlugin, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent]
})
export class AppModule {}
Step 3: Verify Initialization
- Build and run your Cordova or Ionic Native project:
- For Cordova:
cordova run androidorcordova run ios - For Ionic:
ionic cap run androidorionic cap run ios
- For Cordova:
- Test on a device or emulator to ensure the SDK initializes without errors.
- Check the console logs for initialization-related messages (if debug logging is enabled).
Expected Outcome
The SDK will initialize when the application starts, registering with Cordova's lifecycle events and enabling tracking capabilities. You can verify initialization by testing tracking features like events or checking the Apptrove Panel for data.
Best Practices
- Secure SDK Key: Store the SDK key securely in a configuration file or environment variables, avoiding hardcoding in source code.
- Choose the Correct Environment: Use the correct environment constants for your SDK version (Apptrove:
AppTroveEnvironment.*, Trackier legacy:TrackierEnvironment.*) to prevent mixing test and production data. - Initialize Early: Initialize the SDK as early as possible (e.g., after
devicereadyfor Cordova or inngOnInitfor Ionic) to ensure all events are tracked. - Validate Initialization: Test initialization in a development environment and verify the SDK key is recognized in the Apptrove Panel.
- Use Version Control: Commit initialization code to version control to track changes and facilitate collaboration.
- Test Provider Registration: For Ionic Native, ensure the correct provider (
AppTroveCordovaPlugin/TrackierCordovaPlugin) is registered inapp.module.tsto avoid runtime errors.
Troubleshooting
- SDK Key Invalid:
- Verify the SDK key is correctly copied from the Apptrove Panel without extra spaces or characters.
- Ensure the key corresponds to the correct application in the Apptrove Panel.
- Initialization Fails:
- Check console logs for errors related to initialization (
initializeSDK). - Confirm the SDK package is installed under
node_modules(Apptrove:com.apptrove.cordova_sdk, Trackier legacy:com.trackier.cordova_sdk). - For Ionic Native, run
ionic cap syncand verify the import path matches your SDK (com.apptrove.cordova_sdk/ionic-native/apptrove/ngxfor Apptrove,@awesome-cordova-plugins/trackier/ngxfor Trackier legacy).
- Check console logs for errors related to initialization (
- Provider Not Registered (Ionic Native):
- Verify the correct provider (
AppTroveCordovaPlugin/TrackierCordovaPlugin) is imported and added to theprovidersarray inapp.module.ts. - Check for typos in the import path or provider name.
- Verify the correct provider (
- Environment Issues:
- Ensure the environment (
Development,Production, orTesting) matches your deployment stage.
- Ensure the environment (
For further assistance, refer to the Apptrove Documentation Portal or contact Apptrove support at support@apptrove.com.