Identify a contact in a chat widget

SOLVE
Highlighted
Regular Contributor

We're trying to structure a chat flow so that it picks up the name and email of our users in the client interface. Can you advise please?

1 Accepted solution

Accepted Solutions
Highlighted
HubSpot Moderator

Hi, all.

 

If you've implemented theidentifytrackPageView, and HubSpotConversations.widget.refresh() methods outlined above but are still seeing some chats come in as "Unknown Visitors," I can confirm that it is currently expected behavior.

 

Theidentify method critical to the approach HubSpot Developer Support  has heretofore positioned on the Community only directly updates the hubspotutk cookie with the visitor's identity.

 

The conversations (live chat) tool uses a different cookie — messagesUtk— to populate visitor names. If this cookie is not associated with any identity information, a chat will come in under an "Unknown Visitor."

 

HubSpot currently has a back end process which associates the hubspotutk identity information with themessagesUtk cookie, but calling theidentifymethod does not always trigger this process.

 

As such, there is currently no way to guarantee that a chat won't come in under an "Unknown Visitor," even with the method outlined above, which works much of the time.

Our team is working on a dedicated solution for this use case but we currently can't offer a concrete timeframe. Please subscribe to the API Changelog to be notified of the update when it is released.

Apologies for the confusion and thank you in advance for your understanding.

Isaac Takushi

HubSpot Developer Support
14 Replies 14
Highlighted
HubSpot Moderator

Hi, @kporteus.

 

To clarify, are you seeking to identify users with information from your web app before they open a chat?

 

If so, you can accomplish this by triggering the Tracking Code API's identify method, then trackPageView, and then refreshing the chat widget. See @cbarley's example code in this related discussion:

 

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];
    }

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Regular Contributor

Hi Isaac, thanks.

 

We'd like our chatbot to say 'Hi NAME' when they're logged into our web app - as opposed to collecting their name and email address each time.

 

Is this the way to do it?

 

 

 

Reply
0 Upvotes
Highlighted
HubSpot Moderator

Hi, @kporteus.

 

Yes and no.

 

You can use the identify method to avoid asking for the user's name and email each time, but HubSpot chat welcome messages (the first message in a flow) cannot use personalization tokens, like {{ contact.firstname }}. You can call users by their name on subsequent messages, though.

 

Welcome message.jpg

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Regular Contributor

Ok thank you - that should work for us.

 

So just to confirm we need to use the identify method followed by the trackPageView OR just the idendify method?

 

The other thread mentions something about a hard refresh being required - Will the user only be identified if we hard refresh the conversations inbox in HubSpot?

 

We need this to happen automatically so the chat flow can direct the user to their contact owner without the need for any refresh. 

 

Please advise

 

Thanks,

Kerry

Reply
0 Upvotes
Highlighted
HubSpot Alumni

Hey @kporteus , I'll let Isaac continue to work with you on this, but you wouldn't need a hard refresh of the page with a new API we just released. Check out my recent comment here: https://community.hubspot.com/t5/APIs-Integrations/How-to-identify-a-contact-in-the-chat/m-p/272830#...

Highlighted
HubSpot Moderator

Great catch, @cbarley! I've updated my initial response to reflect this fact.

 

@kporteus, as Connor says above, you no longer need to hard refresh the page, but you do need to trigger the following in order:

  1. identify: Stores the data you define (such as name and email) in the tracker.
  2. trackPageView: Passes the data in the tracker into HubSpot so that it can be used in personalization tokens.
  3. HubSpotConversations.widget.refresh(): Refreshes the chat widget so that personalization tokens can populate with known values.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
HubSpot Moderator

Hi, all.

 

If you've implemented theidentifytrackPageView, and HubSpotConversations.widget.refresh() methods outlined above but are still seeing some chats come in as "Unknown Visitors," I can confirm that it is currently expected behavior.

 

Theidentify method critical to the approach HubSpot Developer Support  has heretofore positioned on the Community only directly updates the hubspotutk cookie with the visitor's identity.

 

The conversations (live chat) tool uses a different cookie — messagesUtk— to populate visitor names. If this cookie is not associated with any identity information, a chat will come in under an "Unknown Visitor."

 

HubSpot currently has a back end process which associates the hubspotutk identity information with themessagesUtk cookie, but calling theidentifymethod does not always trigger this process.

 

As such, there is currently no way to guarantee that a chat won't come in under an "Unknown Visitor," even with the method outlined above, which works much of the time.

Our team is working on a dedicated solution for this use case but we currently can't offer a concrete timeframe. Please subscribe to the API Changelog to be notified of the update when it is released.

Apologies for the confusion and thank you in advance for your understanding.

Isaac Takushi

HubSpot Developer Support
Highlighted
Occasional Contributor

Hi there,

 

We are currently trying to use HotSpot Live Chat on our website but ran into some problems. It would be really appreciated if anyone could help 🙂

 

1. We know we could identify users using cookies, but we also want to identify logged in users on our website. If the user doesn't clear cookies and logs in with another account, HotSpot still identifies him as the previous logged in users instead of the new one. Is there any way to solve this?

 

2. When the page gets reloaded, any previous conversations the user has created disappear completely. How could we store the chat history?

 

3. Every time the user sends a message, it creates one conversation in the inbox. Is that possible to integrate all messages from the same users in one place (integrate all conversations) so that we will get a clearer sense of the user's message?

 

 

Same user with multiple conversationsSame user with multiple conversations

Could anyone help please?

 

Thanks in advance. 

 

Reply
0 Upvotes
Highlighted
HubSpot Moderator

Hi, @Teresa1.

 

I'll try to address each of your questions:

 

1. At this time, I cannot think of a good way around this.

 

Removing cookies would create a nighmarish user experience and while identifying visitors would create and update separate contact records with analytics events (i.e. page views), since chatflows identify visitors via the messagesUtk cookie, conversations would be associated with the wrong contact.

 

The dedicated solution for identifying visitors in chatflows which I mention above should help with this use case, but that has yet to enter beta. See @cdewey22's response in this related Community thread.

 

2. Interesting, that has not been my experience. This screen recording shows me refreshing the page after beginning two chats. My chats remain visible after refresh due to the messagesUtk cookie.

 

Per this article, do you have the Consent to collect chat cookies option enabled on your chatflow?

 

3. Not at this time. Assuming conversations are associated with the correct user, the contact record is the best place to view all chats started by the same user in one place.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Occasional Contributor

Hi @IsaacTakushi,

 

i would like to use the live chat without tracking my users. But if i set the doNotTrack-Cookie in the beginning its impossible to set the identity of the user after his login.

 

Is this possible in the dedicated solution?

 

If not, do you have some kind of documentation for the https://api.hubspot.com/livechat-public/v1/thread/visitor REST API? We would implement to JS for UI at our side, but with hubspot REST API as backend.

 

Thanks.

 

Regards

   Steffen...

 

 

Highlighted
HubSpot Moderator

Hi, @stundzigs.

 

Apologies for the delayed response.

 

To clarify, do you wish to be able to identify users via chat but do not wish to capture other analytics or browsing information?

 

I can't speak in detail about how the dedicated solution would interact with other analytics tracking scripts.

Might you be able to speak to this, @cdewey22?

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Occasional Contributor

Hi @IsaacTakushi ,

 

yes that's right. I will only chat with the user and never track them.

 

@cdewey22 do you have a solution for that?

 

Regards

   Steffen...

Reply
0 Upvotes
Highlighted
HubSpot Product Team

Unfortunately, we do not have a solution for this. Chat is part of the Hubspot system so it was intended to work seamlessly with our CRM. We might in the future enable this via API but it is not something we have on our roadmap at the moment.

 

We are working on some more solutions regarding how to present to the customer how to consent to the cookie, including a banner at the beginning of the experience (this already exists today in settings) or a banner at the end of the experience (this is currently being worked, so will be avail in the near future). These options were intended to give your visitor more control over them being cookied. 

 

Also, would love to learn more about your specific usecase though. Feel free to email me at cdewey@hubspot.com so we can continue chatting about how your company is using chat. 

 

Thanks, 

 

Cassie

Reply
0 Upvotes
New Contributor

Hi, 

 

I have kind of a similar situation. 
I am trying to enable the cookie banner for the chat and at the same time being able to 'listen' to the given(or not) consent and pass the information via Google Tag Manager to our cookie consent provider, OneTrust. 

 

I looked into your chat widget API, and the only events available are chat started, chat closed, and chat count changed. There is no event I can listen to. Maybe I am looking into it with the wrong lens, so please any advice is appreciated. 

Thanks

Reply
0 Upvotes