Skip to main content

Passing User Data to 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 (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/core installed (Trackier legacy only: trackier plugin 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

  1. Initialize the SDK with your SDK key and environment.
  2. Create an event object (AppTroveEvent / TrackierEvent) with an event ID to associate with the user data.
  3. Use the plugin methods (e.g., setUserId, setUserEmail, setDOB) to set user details.
  4. Track the event with the associated user data using trackEvent.

Ionic Native (Angular)

tab2.page.ts
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);
}
}

Pure Cordova (JavaScript)

note

In pure Cordova projects, the plugin APIs are exposed as globals after deviceready.

www/js/index.js
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);
}

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-DD format (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 before trackEvent.
    • Ensure the SDK is initialized with the correct SDK key and environment.
    • Check for typos in method names or parameter values.
  • 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 setDOB uses the YYYY-MM-DD format (e.g., "1990-01-01").
    • Verify setGender uses supported values (e.g., "Male", "Female").

For further assistance, refer to the Apptrove Documentation Portal or contact Apptrove support at support@apptrove.com.