How to retrieve a contact's user token through Contacts API?


#1

I have a contact’s vid and I wish to get the user token associated that contact record. What’s the best way to achieve this? The GET /contacts/v1/contact/vid/:contact_id/profile endpoint seems to not return the contact’s usertoken in the response.


#2

Hi @bblatnick

The usertokens (it’s possible for more than one token to be associated with a contact) don’t show up in the data for the contact, and we don’t currently have a way to look those up.

Can you tell me what you’d want to use the uerstoken for?


#3

I see. I want to identify known vs unknown Hubspot visitors coming to my website which means I’d need to know each contact’s user token or tokens. The API seems a bit misleading because the usertoken is returned as a property in http://developers.hubspot.com/docs/methods/contacts/get_contact_by_utk.

Is there any plans to be able to look up user tokens for contacts in the future?


#4

That endpoint won’t return the utk, it only uses the utk to look up a contact record. That endpoint actually sounds like it would do what you’re looking to do. When a visitor hits your site, you can grab the hubspotutk cookie (which gets created by the HubSpot tracking code) from that visitor, and then use that endpoint to see if there’s a contact associated with that cookie. If you get a 404, or a response that includes "is-contact": false then the cookie is not associated with a contact.


#5

Has anything changed in this regard? I know there has been some changes to the API since I asked this question last.


#6

Hi @bblatnick,

It's not currently possible to look up a contact's usertoken(s). The best method to identify known contacts is still to make a call to the 'Get a contact by usertoken' endpoint and look for the "is-contact" field.


#7

Hi @Derek_Gervais, has anything changed with regard to looking up a contact's (or a batch of contacts') usertoken(s) programmatically?

Here is our use case: we would like to send a users' usertoken up to google analytics as the userid. Then, we'd like to pull hubspot contacts and google analytics page view and event data down into a data warehouse and associate the two. With this, we will know the complete visitor journey, and be able to map it all the way down the funnel past conversion.


#8

Hi @nflaherty,

There aren't any updates on this that I'm aware of. I can totally see the use case you're describing, though; If you have the inclination, I would encourage you to check out the Ideas Forum on the HubSpot Community. There, you can create a post including your use case that product and other customers can see.