Create contact from user token


#1

I am using the API in an ecommerce platform. Basically, we have the user token and HubSpot is tracking their activity, but they are not yet a known contact in HubSpot. Once they make a purchase on the website, we now know their email address. What I am trying to do is create a new contact with the email address we have, but make sure we do not lose all of the previous tracking data from the past.

The flow so far is this:

  1. Get the user token from their cookie
  2. Call the API with “contacts/v1/contact/utk/{USER_TOKEN}/profile”
  3. HubSpot returns a result with a vid, but with the “is-contact” field set to false.
  4. Somehow tell HubSpot to upgrade the record to a contact and update the email address field, among others.

4 is where I’m stuck. Trying to update any fields with that vid results in an error message: “Can’t set properties when vid is not a contact.”

Any thoughts on the matter would be appreciated.


#2

Hi @mjarossy

Any records with is-contact false aren’t actually contact records, so they can’t be manually updated. You’ll need to make an association between the contact data and the usertoken. One of the ways to make that association is with a form submission.

Analytics data is collected from the time the visitor first hits the site, and any data collected for the token will show up for the contact record, including the data from before the contact records creation.


#3

That seems to work quite well. Thanks for the help. :grinning:


#4

Hi @dadams,

If I understood right, there is now way to create offline contacts using HS user token (UTK) in a way that all analytics data collected for that UTK will be populated for that contact?

You mentioned the using the form submission for that. Unfortunately this way doesn’t work for us. Is there any other approach to solving this issue, given that we can create offline contact using:

  • UTK
  • email

Thanks!