Passing User Data to SDK
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.
The Apptrove Cordova SDK (Apptrove recommended, Trackier legacy optional) allows you to pass user-specific data, such as user ID, email, name, phone number, date of birth (DOB), and gender, to enhance attribution, personalization, and analytics.
Prerequisites
- Apptrove Cordova SDK installed and initialized 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/coreinstalled (Trackier legacy only:trackierplugin configured)
- Basic knowledge of JavaScript, Angular (for Ionic Native), and Cordova development
Pass User Data
You can pass user details to the Apptrove SDK using dedicated methods to correlate user actions with analytics. This data is typically set after user authentication (e.g., login or registration) and associated with tracked events.
Steps to Pass User Data
- Initialize the SDK with your SDK key and environment.
- Create an event object (
AppTroveEvent/TrackierEvent) with an event ID to associate with the user data. - Use the plugin methods (e.g.,
setUserId,setUserEmail,setDOB) to set user details. - Track the event with the associated user data using
trackEvent.
Ionic Native (Angular)
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
import { Component } from '@angular/core';
import { AppTroveCordovaPlugin, AppTroveConfig, AppTroveEnvironment, AppTroveEvent } from 'com.apptrove.cordova_sdk/ionic-native/apptrove/ngx';
@Component({
selector: 'app-tab2',
templateUrl: 'tab2.page.html',
styleUrls: ['tab2.page.scss']
})
export class Tab2Page {
constructor(private apptroveCordovaPlugin: AppTroveCordovaPlugin) {}
async ngOnInit() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var appTroveConfig = new AppTroveConfig(key, AppTroveEnvironment.Development);
this.apptroveCordovaPlugin.initializeSDK(appTroveConfig);
// Pass User Data and Track Event
var event = new AppTroveEvent("YOUR_EVENT_ID"); // Event ID
event.setCouponCode("TestCode");
await this.apptroveCordovaPlugin.setUserId("TestUserId");
await this.apptroveCordovaPlugin.setUserName("Jane Doe");
await this.apptroveCordovaPlugin.setUserPhone("+1234567890");
await this.apptroveCordovaPlugin.setUserEmail("jane.doe@example.com");
await this.apptroveCordovaPlugin.setDOB("1990-01-01"); // YYYY-MM-DD
await this.apptroveCordovaPlugin.setGender("Male"); // Male / Female / Others
this.apptroveCordovaPlugin.trackEvent(event);
}
}
Trackier SDK will be deprecated in August 2026. Migrate to Apptrove SDK 2.x for ongoing support.
import { Component } from '@angular/core';
import { TrackierCordovaPlugin, TrackierConfig, TrackierEnvironment, TrackierEvent } from '@awesome-cordova-plugins/trackier/ngx';
@Component({
selector: 'app-tab2',
templateUrl: 'tab2.page.html',
styleUrls: ['tab2.page.scss']
})
export class Tab2Page {
constructor(private trackierCordovaPlugin: TrackierCordovaPlugin) {}
async ngOnInit() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
this.trackierCordovaPlugin.initializeSDK(trackierConfig);
// Pass User Data and Track Event
var event = new TrackierEvent("YOUR_EVENT_ID"); // Event ID
event.setCouponCode("TestCode");
await this.trackierCordovaPlugin.setUserId("TestUserId");
await this.trackierCordovaPlugin.setUserName("Jane Doe");
await this.trackierCordovaPlugin.setUserPhone("+1234567890");
await this.trackierCordovaPlugin.setUserEmail("jane.doe@example.com");
await this.trackierCordovaPlugin.setDOB("1990-01-01"); // YYYY-MM-DD
await this.trackierCordovaPlugin.setGender("Male"); // Male / Female / Others
this.trackierCordovaPlugin.trackEvent(event);
}
}
Pure Cordova (JavaScript)
In pure Cordova projects, the plugin APIs are exposed as globals after deviceready.
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating August 2026)
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var appTroveConfig = new AppTroveConfig(key, AppTroveEnvironment.Development);
AppTroveCordovaPlugin.initializeSDK(appTroveConfig);
// Pass User Data and Track Event
var event = new AppTroveEvent("YOUR_EVENT_ID");
AppTroveCordovaPlugin.setUserId("TestUserId");
AppTroveCordovaPlugin.setUserName("Jane Doe");
AppTroveCordovaPlugin.setUserPhone("+1234567890");
AppTroveCordovaPlugin.setUserEmail("jane.doe@example.com");
AppTroveCordovaPlugin.setDOB("1990-01-01"); // YYYY-MM-DD
AppTroveCordovaPlugin.setGender("Male"); // Male / Female / Others
AppTroveCordovaPlugin.trackEvent(event);
}
Trackier SDK will be deprecated in August 2026. Migrate to Apptrove SDK 2.x for ongoing support.
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
// Initialize SDK
var key = "0455721b-XXXX-XXXXX-596d818d910a"; // Replace with your SDK key
var trackierConfig = new TrackierConfig(key, TrackierEnvironment.Development);
TrackierCordovaPlugin.initializeSDK(trackierConfig);
// Pass User Data and Track Event
var event = new TrackierEvent("YOUR_EVENT_ID");
TrackierCordovaPlugin.setUserId("TestUserId");
TrackierCordovaPlugin.setUserName("Jane Doe");
TrackierCordovaPlugin.setUserPhone("+1234567890");
TrackierCordovaPlugin.setUserEmail("jane.doe@example.com");
TrackierCordovaPlugin.setDOB("1990-01-01"); // YYYY-MM-DD
TrackierCordovaPlugin.setGender("Male"); // Male / Female / Others
TrackierCordovaPlugin.trackEvent(event);
}
Parameters
- User ID: A unique identifier for the user (e.g.,
"TestUserId"). - User Name: The user's name (e.g.,
"testName"). - User Phone: The user's phone number (e.g.,
"XXXXXXX"). - User Email: The user's email address (e.g.,
"sanu@gmail.com"). - DOB: The user's date of birth in
YYYY-MM-DDformat (e.g.,"1990-01-01"). - Gender: The user's gender (e.g.,
"Male","Female"). - Coupon Code: An optional coupon code associated with the event (e.g.,
"TestCode").
Expected Outcome
The user data will be associated with the tracked event and sent to the Apptrove, enabling correlation with analytics in the Apptrove Panel. Verify by checking user data in the dashboard or event logs.
Best Practices
- Pass Data After Authentication: Set user data immediately after user login or registration to ensure accurate attribution.
- Validate User Data: Ensure data is valid (e.g., properly formatted email, non-empty user ID, correct DOB format) to avoid tracking errors.
- Use Meaningful Data: Provide relevant user details to enrich analytics and support personalization.
- Test in Development Mode: Use a development/testing environment to validate user data tracking without affecting production data.
- Comply with Privacy Regulations: Ensure user data handling complies with GDPR, CCPA, and other privacy laws, obtaining user consent where required.
- Secure Data Storage: Avoid hardcoding sensitive user data in source code; use secure storage or environment variables.
Troubleshooting
- User Data Not Appearing in Dashboard:
- Verify that user data methods (e.g.,
setUserId,setUserEmail) are called beforetrackEvent. - Ensure the SDK is initialized with the correct SDK key and environment.
- Check for typos in method names or parameter values.
- Verify that user data methods (e.g.,
- Event Not Tracked:
- Confirm the event ID is valid and matches the Apptrove Panel.
- Check console logs for errors related to
trackEvent.
- Invalid DOB or Gender:
- Ensure
setDOBuses theYYYY-MM-DDformat (e.g.,"1990-01-01"). - Verify
setGenderuses supported values (e.g.,"Male","Female").
- Ensure
For further assistance, refer to the Apptrove Documentation Portal or contact Apptrove support at support@apptrove.com.