Getting user by user token failing


#1

I had an idea that I thought I’d test out. It requires getting the contact record via the user token set in the hubspot cookie.

I took a look at my own cookie, got the user token, along with an API key for the hub and used them in a url constructed like so:

http://api.hubapi.com/contacts/v1/contact/utk/my-user-token-redacted/profile?hapikey=redacted

But I get the result:

{"status":"error","message":"contact does not exist","correlationId":"redacted","requestId":"redacted"}

Any ideas as to why?


#2

Hi @nathansmonk

Usertokens are randomly generated when a visitor first hits your site, so there won’t be any data for a usertoken until it has data that’s been logged and processed by the HubSpot analytics system. Also, get a contact record for a usertoken until something associates the usertoken with a specific contact (a form submission is the most common way for that association to happen).


#3

Sorry, I don’t understand @dadams.

What does:

until it has data that’s been logged and processed by the HubSpot analytics system

…mean?

Are you saying that a cookie id isn’t always linked to a contact record? In that case, the cookie id I used would have been related to a user as I have been logged through a contact form for many months.