Skip to content

Instantly share code, notes, and snippets.

@leadbi
Forked from andrei-tofan/private_area.js
Last active April 1, 2021 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leadbi/908e9d8501cafc14082d99e6fe9bcd3e to your computer and use it in GitHub Desktop.
Save leadbi/908e9d8501cafc14082d99e6fe9bcd3e to your computer and use it in GitHub Desktop.
LeadBI user identification api
// check if $leadbi_website api is available
if(window.$leadbi_website){
// fetch user object of the current visitor
window.$leadbi_website.getCurrentUser(function (err, user) {
// call the identify api
// calling this method multiple times for the same email address will not create duplicate contacts
return user.identify({
first_name: 'John', // optional,
last_name: 'Doe', // optional
email: 'john.doe@test.com', // required
company: 'Test Inc', // optional
role: 'CEO', // optional
attributes: { // other attributes to be associated with the user
example_attribute: 'test'
}
}, function (err) {
if(err){
// something went wrong
}else{
// the user has been identified / created in leadbi
}
})
});
// fetch user object of the current visitor
window.$leadbi_website.getCurrentUser(function (err, user) {
// fetch all the information form leadbi about this user
return user.getProfile(function (err, profile) {
if(err){
// something went wrong
}
// user profile data has been returned
console.log(profile)
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment