APIs & Integrations

iqnection
Participant | Gold Partner
Participant | Gold Partner

Create contact from user token

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.

0 Upvotes
3 Replies 3
germaniakovlev
Member

Create contact from user token

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!

0 Upvotes
iqnection
Participant | Gold Partner
Participant | Gold Partner

Create contact from user token

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

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Create contact from user token

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.

Submit data to a form | HubSpot Forms API

POST https://forms.hubspot.com/uploads/form/v2/:portal_id/:form_guid - Send form submission data to HubSpot. Form submissions from external sources can be made to any registered HubSpot form. You can see a list of forms on your portal by going to...

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.

0 Upvotes