APIs & Integrations

LukaszWiktor
参加者

How to identify a contact in the chat?

解決

Hi,

how can I identify a visitor in the chat box? I've tried the identify API

 var _hsq = window._hsq = window._hsq || []; 
_hsq.push(["identify", { email: "${email}" }]);

but it didn't work. New chat conversations still appear as "Uknown Visitor"

I'd appreciate your help.

Thanks,
Lukasz

1件の承認済みベストアンサー
tilly
解決策
HubSpot製品開発チーム
HubSpot製品開発チーム

How to identify a contact in the chat?

解決

The Visitor Identification API is now in public beta! You can read more about it and get started here. This is open to all Pro+ portals as of now, no need to be ungated. 

 

The new Visitor Identification API enables you to provide details about visitors' identities to the chat widget after they've been authenticated by an external login system. So, if a visitor logs in (by providing their email address), the Visitor Identification API can send their identity to HubSpot's chat widget.

 

This API also works automatically with HubSpot's private content membership for CMS Hub or Knowledge Base, no additional setup required!

 

Please let me know if you have any questions or feedback. This API is still in beta, by using this API you agree to our developer beta terms.

元の投稿で解決策を見る

116件の返信
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

解決

Welcome, @Ferdy.

 

If you include an email field in the chat itself, you will be able to identify users every time. This discussion pertains to customers who want to identify users without having to rely on the in-chat email field.


Let me know if I've misunderstood your question.

Isaac Takushi

Associate Certification Manager
0 いいね!
Ferdy
メンバー

How to identify a contact in the chat?

解決

I meant, will we be able to use a LiveChat API that simply allows for putting email/identifying information to the support side, so indeed without relying on the in-chat email field. But also without relying on the tracking API/cookies. So something like:

 

window.HubSpotConversations.widget.identify({email: loggedInUserEmail});

 

0 いいね!
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

解決

Gotcha, @Ferdy. Thanks for clarifying.

 

To my knowledge, the solution @cdewey22 mentions in this post is a Live Chat API function which would perform similarly to what you described.

Isaac Takushi

Associate Certification Manager
0 いいね!
hostimi
参加者

How to identify a contact in the chat?

解決

Isaac,

 

The problem I observe is that when I use:

_hsq.push(["identify", {
        email: "foo@bar.com",
        company: "Foo"
}]);

is that it will create a record in Hubspot CRM which is not always what I want.

I just want to identify the person in chat but DO NOT create a record in CRM for that.

There should be separate method for identifying in chat only, like:

 

window.HubSpotConversations.widget.identify({email: loggedInUserEmail});

or a flag that can indicate that, like:

 

_hsq.push(["identify", {
        email: "foo@bar.com",
        chatOnly: true
}]);
IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

解決

Hi, @hostimi.

 

You're correct that the identify function will always create a new contact record for new email addresses.

 

I believe the upcoming functionality will support the use case you describe. From my understanding, it will allow you to identify visitors for chats without creating them.

Isaac Takushi

Associate Certification Manager
justindocanto
メンバー

How to identify a contact in the chat?

解決

Any update on this pending functionality? Running into the issue right now where chats are coming from "unknown sender" but they assume we know who they are. Being able to label who is contacting us is absolutely necessary for this to be useful to us.

0 いいね!
hostimi
参加者

How to identify a contact in the chat?

解決

Isaac,

 

> From my understanding, it will allow you to identify visitors for chats without creating them.

 

yes, this is exactly what I need

NicolássHanckes
参加者

How to identify a contact in the chat?

解決

We were about to migrate the chat from Intercom to Hubspot to integrate marketing and sales with service, but not being able to recognize logged in customers properly is a huge loss for us. Might need to cancel our pro subscriptions until this issue is solved.

IsaacTakushi
HubSpot Employee
HubSpot Employee

How to identify a contact in the chat?

解決

Hi, @vruben.

 

I hear you and the team recognizes this is critical functionality.

 

They're going to devote resources to this in the new year, but I'm afraid I don't have a more concrete ETA.

Isaac Takushi

Associate Certification Manager
sp3
参加者

How to identify a contact in the chat?

解決

Hello,

 

we are experiencing the same problem with our users, that are logged in to our platform. Having to ask them about whom they are, drastically reduces the customer experience. We have migrated to HubSpot from intercom, following of the need to have it all in one place. We had no such issues with our previous provider 😞

0 いいね!
tbrito85
参加者

How to identify a contact in the chat?

解決

Hello @IsaacTakushi  thanks on answering.

 

We´re eagerly awaiting a solution.

This is essential to identify logged in users in Saas.

builtbyeric
メンバー

How to identify a contact in the chat?

解決

@cbarley Thanks much for this info.  I'm new to HubSpot (and Javascript) so I don't have a strong foundation, but I could really use some clarity around how this works. I believe my problem matches this thread topic: We're using the HubSpot Conversations API, and we're having conversations show up as Unknown Visitor. My issue is not that it doesn't work, it's that it's not reliably working. We have a SPA React app and we're following the instructions on this page, and we often get a contact associated with the name, but frequently we don't. What we're seeing is:

 

* When opening an incognito window and logging in for the first time, we get Unknown Visitor about 20% of the time.
* After logging out of our app then logging back in, we get Unknown Visitor 100% of the time. Logging out and logging back in again will usually resolve it, although sometimes the name received in HubSpot is actually the previous login, not the current one.

 

When the identity changes, we push the new identity and trackPageView per this thread.
When the location changes, we setPath and trackPageView.
When the user logs out, we revokeCookieConsent and trackPageView, then clear the converation, refresh the widget and reload the page.

 

I've removed as much uncertainty as I can: Everything going to hubspot is serialized, has a widget refresh after each operation, and only runs the next operation once the refresh (or reload) is finished. I've verified we're sending the correct email and the events are in order. As far as I know the tracking code is being triggered and it's always sending the correct email (I assume https://track.hubspot.com/__ptq.gif is the tracking URL, that's where I'm seeing the identity attached).

 

Everything looks good, and more importantly, everything seems to be the same every time, but it's just random whether or not we'll get an Unknown Visitor. Is there any insight in to how this works?

Frat
メンバー

How to identify a contact in the chat?

解決

Hi,

 

On our platform all visitors must be logged in which means that for all connexions we have their email address and they are registered in our Hubspot CRM.

 

I am wondering why there is no feature in the Conversations API that enables to push throught the visitor email address while the chat is loading? So, if the visitor starts a conversation we can identify him in Hubsport and/or Slack or whatever other tool we are using to engage with him.

 

It would be much easier than using cookies and three different APIs (from what I've understand from technical documentation and from this thread). But I might have missed something... is there any feature in the Conversations API where we could post the visitor's email address each time the chat loads to make sure to identify him if he engages the conversation?

 

Thanks,

Madura
メンバー

How to identify a contact in the chat?

解決

This is worked for you since you have used email "test@testing.com". JUst change it to something else and it won't work.

0 いいね!
cbarley10
投稿者

How to identify a contact in the chat?

解決

Hey @Madura , I tested with a real email address and it worked again with the exact code above. You just need to 1. push the data into the tracking code by using an identify call 2. call a trackPageView or trigger an event to send that data to HubSpot 3. Refresh the widget immediately and the user can then chat. This will identify the contact inside of the Conversations Tool inside of HubSpot. Not totally sure about identifying the user within the literal chat widget, but I just might not have tested enough. It seems like it should be possible though

0 いいね!
israelj
メンバー

How to identify a contact in the chat?

解決

Hi, 

 

I'm trying to follow your example but it seems some of your code is missing. How do you utilize the call to sendIdentify()?

 

Thanks!

0 いいね!
damdam
参加者

How to identify a contact in the chat?

解決

@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):

window._hsq = window._hsq || [];
window._hsq.push([
  "identify",
  { email: "email@example.com" }
]);
window._hsq.push(["trackPageView"]);

window.HubSpotConversations.widget.refresh();

Nothing happens when I do that. 

What I noticed is that when this happens I find the following response for the network request issued by your code to the url:  https://api.hubspot.com/livechat/v1/message/public?portalId=XXXXX&...&mobile=false&messagesUtk=YYYY

{"@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!

 

0 いいね!
cbarley
元HubSpot社員
元HubSpot社員

How to identify a contact in the chat?

解決

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.

0 いいね!
damdam
参加者

How to identify a contact in the chat?

解決

Hi @cbarley , thanks for the quick reply!

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!

0 いいね!
dboskovic
メンバー

How to identify a contact in the chat?

解決

Can confirm that it doesn't work on localhost which definitely caused some confusion. Example works in production.

jordand
メンバー

How to identify a contact in the chat?

解決

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