The “identify” method of the Tracking Code API only stores the identity information in the tracker; you’ll need to call the “trackEvent” or “trackPageView” method to actually pass the identity info to HubSpot. Are you both subsequently calling one of these events?
Is this true even after a page refresh? My gut tells me that the contact identification is working, but the messages client isn’t being updated with the identity info. Can you try making the association, then refreshing?
Hiii
I have same issue but after refreshing it’s identified in chat conversation. I have SPA in Angular 5. Any other solution for Why should i have to refresh.??
My problem is that I need to re-identify my users upon logout / another login, but it seems that the first identify is stucked, and when the chat widget opens, the previous history shows up, and the messages goes in the name (email) of the first identified user no matter if I call again the window._hsq.push([ “identify”, { email: .. } ]). What is the proper way to re-identify the chat so I could handle my single page app logout/login process?
@Derek_Gervais I’m using Forms API to submit hubspotutk along with contact name/email/ip upon login, yet I still need to refresh for the contact to be recognized by the bot.
When the user was just logged in for the first time, it’s still considered an unknown visitor by the bot, and simply one more refresh would solve the issue. It has nothing to do with timing, I tried dynamically loading the script 10 seconds after the page was fully loaded upon login but I still had to refresh one more time to have the bot recognize the contact.
Was there ever a solution on this? we have the same problem, visitors are identified as unknown until refresh the page we only want to show chat to people in a targeted segment, so need to know who they are and not hope that they refresh the page, on a single page application
Hey all, we recently came out with a Conversations JavaScript API, where you wouldn’t have to refresh the page. This is great for SPAs because now you can just refresh the widget and not the page itself. After some quick testing on a page of my own, I was able to identify the contact, refresh the widget programmatically, then have the ability to see the contact’s email address within the Conversations tool.
screenshot: Screenshot by Lightshot
We still can’t use personalization tokens inside the chat unless you’re using bots, but now the contacts you identify won’t show up as “Anonymous Visitor”. Here’s the code I used:
function onConversationsAPIReady() {
var _hsq = window._hsq = window._hsq || [];
console.log("ready")
_hsq.push(["identify",{
email: "test@testing.com" }]);
_hsq.push(['trackPageView']);
setTimeout( () => {
console.log("refresh")
window.HubSpotConversations.widget.refresh();
}, 1000)
}
function sendIdentify(){
if (window.HubSpotConversations) {
onConversationsAPIReady();
} else {
window.hsConversationsOnReady = [onConversationsAPIReady];
}
feel free to keep testing, but just wanted to make sure you were aware of this new JS API we have.
@cbarley Thanks for your precious feedback!
I’ve been spending the last few hours on this but I’m still having issues in using the refresh API.
I’m using the exact same code you posted; I also verified that things are lined up just fine temporally (the sequence of events is correct: once the hsConversation API is ready my code pushes the “identify” value and the “trackPageView” into _hsq and then calls the refresh function).
Though, nothing happens, my user is still “unknown” to HubSpot (even though I’ve provided id and email matching one of my contacts).
Similarly, if I setup the Chatflow to show only for tracket contacts, the widget never shows, even though I provide the id and email of the contact before calling refresh.
I still need to do a hard reload of the page to see the widget popping up.
This is the code I run (in a simplified version, without setTimeout and fake data):
{"@type":"HIDE_WIDGET","type":"HIDE_WIDGET","metadata":{"@type":"HIDE_WIDGET_META","reason":"NO_MATCHING_WELCOME_MESSAGE","description":"No matching welcome message for portal XXXXX page http://localhost:3000/mypageurl or visitor does not match targeting rules"}}
Might this be linked to the widget not refreshing as intended?
Ah, one additional thing:
I noticed that if I open my contact detail page in HubSpot, I correctly see ALL the “trackPageView” events I pushed!
Even though the chat widget keep not recognizing the user (unless I refresh the page), the “trackPageView” event I push seems to correctly reach HubSpot and map to the correct contact!
Hi @damdam , the contact’s name or email can’t show inside the chat bubble since personalization tokens aren’t able to be used in that setting, but if you identify the contact, you should be able to see in the Conversations Tool inside HubSpot that they aren’t an Unknown Visitor anymore.
The weirdness of that behavior you’re seeing right now could also be because you’re testing on localhost. I’ve seen strange behavior there so you should probably just test out on an unpublished test page in HubSpot.
I’m aware of the issue with the personalization token
That’s not what I was talking about. My problem is exactly what you guessed: in HubSpot the visitor is not recognized as a contact and shows up as “Unknown visitor” (until I refresh the browser page that is, from that moment onward it is properly recognized).
I honestly don’t see why using localhost might be a problem, since there’s no mention of any domain in Hubspot (so HubSpot wouldn’t be able to apply any special behaviour depending on the URL of the incoming request); if that was the case, I would expect the visitor not to be recognized, ever, not even after a page refresh (and that is not the case).
I’ll try connecting through a tunnel (to proxy my localhost address through a public address) and see if there’s any difference but I won’t hold my breath on this.. I’ve a feeling that it won’t change that much.
I’ll keep you posted
Thanks again for the prompt feedback, much appreciated!