Skip to main content

Identifying Users

You can identify users using the userIdentifier method provided by our SDK. This method requires a unique identifier for your user.

Nudge.userIdentifier(
"sample_id" //Client identifiable unique ID
);

Sending User Details

The userIdentifier method takes a second parameter that is an object where you can send the user details. This object has 4 fields name , email , phoneNumber and properties. You can further add more data ito the properties object.

note

The name, email, and phoneNumber of the user are passed outside the properties object.

Nudge.userIdentifier(
"sample_id", //externalId : Client identifiable unique ID

{
name: "Sample User", //optional
email: "[email protected]", //optional
phoneNumber: "9999999999", //optional
properties: {
//User properties
age: 25,
location: "India",
},
}
);

Signing out users

Once the user signs out from your application, use the userSignOut method provided by Nudge to clear any cached data for that user.

Nudge.userSignOut();

Identifying users from Android side

For applications with a hybrid structure, where some features are implemented in native Android and others in React Native, you can identify users directly from the Android side using the following snippet:


HashMap<String, Object> properties = new HashMap<>();
properties.put("age", 30);
properties.put("subscribed", true);


Nudgecorev2ReactNativeModule.NudgeReactNative.userIdentifier(
"externalId123", // externalId (non-nullable)
"John Doe", // name (nullable)
"[email protected]", // email (nullable)
"9999999999", // phone (nullable)
properties // props (nullable)
);


Signing out users from Android Side

For a hybrid structure you can use the below snippet to sign out users from the Android side :

Nudgecorev2ReactNativeModule.NudgeReactNative.userSignOut()


Adding Leads

The Nudge SDK allows you to add leads using the addLeads method. This method links a lead (Person B) to the user (Person A) who added them. Later, when the lead (Person B) logs in, Nudge ensures the lead is correctly attributed to the original user who added them (Person A).

Example:

  • Person A adds Person B as a lead: Person A gives Person B an externalId (e.g., "user_b").
  • Person B logs in: Person B uses the same externalId ("user_b") to log in

By keeping the externalId consistent, Nudge ensures accurate tracking and attribution of leads in your application.

const leads = [
{
externalId: "1234",
name: "John Doe",
email: "[email protected]",
phoneNumber: "1234567890",
properties: { age: 30, city: "New York" },
},
{
externalId: "4567",
name: "Jane Smith",
email: "[email protected]",
phoneNumber: "123456789",
properties: { age: 25, city: "San Francisco" },
},
];
Nudge.addLeads(leads);
note
  • The extId of the lead should be the same when they login using the userIdentifier method.
  • The name, email, and phoneNumber of the lead are passed outside the properties object.

Adding Callbacks for Success and Failure

You can pass onSuccess and onFailure callback functions to handle responses or errors when adding leads.

// Define the success callback
const onSuccess = (response) => {
console.log('Leads added successfully:', response);
};

// Define the failure callback
const onFailure = (error) => {
console.error('Failed to add leads:', error);
};

// Call the addLeads method with callbacks
Nudge.addLeads(
leads,
onSuccess,
onFailure
);