Identifying Users
Track users and their properties in your web application.
You can identify users using the userIdentifier
method provided by our SDK. This method required a unique identifier for your user. You can also pass additional user properties inside a properties
object.
You can also send more user attributes along with the user ID for making segments of audiences.
To see the name, email, and phone number of the user in Nudge's dashboard, make sure to pass these properties outside the props object.
await nudge.userIdentifier({
externalId: "CLIENT_IDENTIFIABLE_USER_ID",
name: "Client User 1",
email: "[email protected]",
properties: {
age: 27,
gender: "M",
country: "US",
},
});
Applying Referrals
In the Nudge dashboard, you can set up referral codes for all users. Each user gets a unique referral code automatically. When a new user provides a valid referral code, you can pass that referral code in the referralCode
field.
await nudge.userIdentifier({
externalId: "CLIENT_IDENTIFIABLE_USER_ID",
name: "Client User 1",
email: "[email protected]",
referralCode : "VALID_REFERRAL_CODE"
});
Additionally, the SDK will emit an event with the name nudgeReferralCompleted
. You can listen to this event to track when a referral is successfully applied.
Example: Listening to successful referral
document.addEventListener('nudgeReferralCompleted', function (event) {
console.log("EVENT message", event.detail.status, event.detail.message);
});
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.
await nudge.userSignOut();