-
-
Save leadbi/908e9d8501cafc14082d99e6fe9bcd3e to your computer and use it in GitHub Desktop.
LeadBI user identification api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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