Hi everyone,
I am using the below code but the users info is not passing into Hubspot CRM and my users are still showing as unknown visitor. how do i make it automatically create a contact so when responding to my website chats through the hubspot portal i know which user i am talking to by first name without them having to give the bot the first name?
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/<?php echo $hubspotID; ?>.js"></script>
<script type="text/javascript">
function onConversationsAPIReady() {
var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
email: "<?php echo $userEmail; ?>",
firstname: "<?php echo $userFN; ?>",
lastname: "<?php echo $userLN; ?>",
user_id: "<?php echo $userID; ?>",
project_id: "<?php echo $userProject; ?>"
}]);
_hsq.push(['trackPageView']);
setTimeout( () => {
window.HubSpotConversations.widget.refresh();
}, 1000)
}
function sendIdentify(){
window.HubSpotConversations.on('conversationClosed', payload => {
});
}
if (window.HubSpotConversations) {
onConversationsAPIReady();
sendIdentify();
} else {
window.hsConversationsOnReady = [onConversationsAPIReady, sendIdentify];
}
</script>