Passing User Data to SDK
The Trackier Cordova SDK 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 correlation with Trackier analytics. This section outlines how to pass user data to the SDK for improved tracking and user experience.
Prerequisites
- Trackier Cordova SDK installed and initialized in your project
- A Trackier MMP account with access to the Trackier Panel
- Cordova 9.0 or later
- For Ionic Native apps:
- Ionic CLI and Capacitor
@awesome-cordova-plugins/core
andtrackier
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 Trackier 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 a
TrackierEvent
object with an event ID to associate with the user data. - Use
trackierCordovaPlugin
methods (e.g.,setUserId
,setUserEmail
,setDOB
) to set user details. - Track the event with the associated user data using
trackEvent
.
- Iconic Native
- Pure Cordova
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 trackierEvent = new TrackierEvent("1CFfUn3xEY"); // Event ID
trackierEvent.setCouponCode("TestCode");
this.trackierCordovaPlugin.setUserId("TestUserId");
this.trackierCordovaPlugin.setUserName("testName");
this.trackierCordovaPlugin.setUserPhone("XXXXXXX");
this.trackierCordovaPlugin.setUserEmail("sanu@gmail.com");
this.trackierCordovaPlugin.setDOB("12/1/2022");
this.trackierCordovaPlugin.setGender("Male");
this.trackierCordovaPlugin.trackEvent(trackierEvent);
}
}
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 trackierEvent = new TrackierEvent("1CFfUn3xEY"); // Event ID
trackierEvent.setCouponCode("TestCode");
TrackierCordovaPlugin.setUserId("TestUserId");
TrackierCordovaPlugin.setUserName("testName");
TrackierCordovaPlugin.setUserPhone("XXXXXXX");
TrackierCordovaPlugin.setUserEmail("sanu@gmail.com");
TrackierCordovaPlugin.setDOB("12/1/2022");
TrackierCordovaPlugin.setGender("Male");
TrackierCordovaPlugin.trackEvent(trackierEvent);
}
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
MM/DD/YYYY
format (e.g.,"12/1/2022"
). - 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 Trackier MMP, enabling correlation with analytics in the Trackier 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
TrackierEnvironment.Development
to test 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 Trackier Panel.
- Check console logs for errors related to
trackEvent
.
- Invalid DOB or Gender:
- Ensure
setDOB
uses theMM/DD/YYYY
format (e.g.,"12/1/2022"
). - Verify
setGender
uses supported values (e.g.,"Male"
,"Female"
).
- Ensure
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.