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.0.0)
  • Trackier SDK → Will be deprecated in May 2026 (v1.x.xx)

Use the tabs below to view user data code for your chosen SDK.

The Apptrove React Native SDK allows you to pass user-specific data, such as user ID, email, name, phone number, and additional custom details, to enhance attribution, personalization, and correlation with Apptrove analytics. This section outlines how to pass user data to the SDK for improved tracking and user experience.

Prerequisites

  • Apptrove React Native SDK installed and initialized in your project
  • A Apptrove MMP account with access to the Apptrove Panel
  • React Native 0.60 or later
  • Basic knowledge of JavaScript and React Native development

Pass User Data

You can pass core user details (e.g., user ID, email, name, phone) and additional custom data to the Apptrove SDK using dedicated methods. This data helps correlate user actions with Apptrove analytics and supports personalized experiences.

Step 1: Pass Core User Details

Use the SDK methods to set user ID, email, name, and phone number. These details can be passed after SDK initialization, typically when a user logs in or registers.

JavaScript Example
App.js
import React from 'react';
import { ApptroveConfig, ApptroveSDK, ApptroveEvent } from 'react-native-apptrove';
import { StyleSheet, Text, View, TouchableHighlight } from 'react-native';

export default function App() {
const apptroveConfig = new ApptroveConfig("xxxx-xx-4505-bc8b-xx", ApptroveConfig.EnvironmentDevelopment);
ApptroveSDK.initialize(apptroveConfig);

const setUserDetails = () => {
const apptroveEvent = new ApptroveEvent(ApptroveEvent.ADD_TO_CART);
ApptroveSDK.setUserId("XXXXXXXX"); // Set user ID
ApptroveSDK.setUserEmail("abc@gmail.com"); // Set user email
ApptroveSDK.setUserName("abc"); // Set user name
ApptroveSDK.setUserPhone("813434721"); // Set user phone
ApptroveSDK.trackEvent(apptroveEvent); // Track an event with user data
};

return (
<View style={styles.container}>
<TouchableHighlight style={styles.button} onPress={setUserDetails}>
<Text>Set User Details</Text>
</TouchableHighlight>
</View>
);
}

const styles = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center' },
button: { padding: 10, backgroundColor: '#ddd' },
});

Step 2: Pass Additional User Data

For additional user details (e.g., age, gender, or custom attributes), create a JavaScript object and pass it to the setUserAdditionalDetails method. This allows for flexible data tracking tailored to your app's needs.

JavaScript Example
App.js
import React from 'react';
import { ApptroveConfig, ApptroveSDK, ApptroveEvent } from 'react-native-apptrove';
import { StyleSheet, Text, View, TouchableHighlight } from 'react-native';

export default function App() {
const apptroveConfig = new ApptroveConfig("xxxx-xx-4505-bc8b-xx", ApptroveConfig.EnvironmentDevelopment);
ApptroveSDK.initialize(apptroveConfig);

const setAdditionalUserDetails = () => {
const apptroveEvent = new ApptroveEvent(ApptroveEvent.ADD_TO_CART);
ApptroveSDK.setUserId("XXXXXXXX"); // Set user ID
ApptroveSDK.setUserEmail("abc@gmail.com"); // Set user email
ApptroveSDK.setUserName("abc"); // Set user name
ApptroveSDK.setUserPhone("813434721"); // Set user phone
const jsonData = { phone: "+91-8137872378", name: "Embassies" };
ApptroveSDK.setUserAdditionalDetails("data", JSON.stringify(jsonData)); // Set additional details
ApptroveSDK.trackEvent(apptroveEvent); // Track an event with user data
};

return (
<View style={styles.container}>
<TouchableHighlight style={styles.button} onPress={setAdditionalUserDetails}>
<Text>Set Additional User Details</Text>
</TouchableHighlight>
</View>
);
}

const styles = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center' },
button: { padding: 10, backgroundColor: '#ddd' },
});

Parameters

  • User ID: A unique identifier for the user (e.g., "XXXXXXXX").
  • User Email: The user's email address (e.g., "abc@gmail.com").
  • User Name: The user's name (e.g., "abc").
  • User Phone: The user's phone number (e.g., "813434721").
  • Additional Details: A JavaScript object containing custom key-value pairs (e.g., { phone: "+91-8137872378", name: "Embassies" }), passed with a key (e.g., "data").

Expected Outcome

The user data will be associated with the SDK and correlated with events tracked in the Apptrove Panel, enabling enhanced analytics and personalization. Verify by checking user data in the Apptrove Panel or through associated event logs.

Best Practices

  • Pass Data After Login: Set user data immediately after user authentication (e.g., login or registration) to ensure accurate attribution.
  • Validate User Data: Ensure user data is valid (e.g., properly formatted email, non-empty user ID) to avoid tracking errors.
  • Use Meaningful Custom Data: Include relevant custom details (e.g., user preferences, demographics) to enrich analytics and personalization.
  • Test in Development Mode: Use ApptroveConfig.EnvironmentDevelopment or TrackierConfig.EnvironmentDevelopment 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 SDK methods (e.g., setUserId, setUserEmail) are called after SDK initialization (ApptroveSDK.initialize or TrackierSDK.initialize).
    • Ensure the environment (EnvironmentDevelopment or EnvironmentProduction) matches the Apptrove Panel settings.
    • Check for typos in method names or parameters.
  • Additional Details Not Tracked:
    • Confirm the jsonData object is valid and contains supported key-value pairs.
    • Ensure setUserAdditionalDetails is called with the correct key (e.g., "data") and object.
  • General Issues:
    • Check console logs for errors related to SDK methods (ApptroveSDK or TrackierSDK).

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