Submission of Form with same hutk ID creates two separate Contacts, deduplication fails

SOLVE
advance512
Contributor

Hi there,

 

We have Cookie Tracking enabled in our system. We have several subdomains, all under the same domain. We have two main Forms that we submit data into (well, we have more, but these are the ones that most matter), and both have Cookie Tracking enabled. We also allowed the submission of Forms without email addresses.

 

I verified that the `hutk` value is the same for both. However, the data is not merged into the same Contact, rather, a new Contact is created.

 

Here's an example. There are two hubspotutk tracking cookies set:

.hubspot.com - b83ef551ca9874da6d1df7aec21518c0

.whatever.com - 9970c73472b9c359e72e603a4ccb329a

 

The following forms were submitted first via https://welcome.whatever.com and later on https://app.whatever.com.

 

Form 1, welcome.whatever.com, without an email:

phone: +972 12-345-6789
firstname: Myname
lastname: Intomato4
company: Intomato4
website: http://www.intomato4.com
hs_persona: persona_1
hs_context: {"hutk":"9970c73472b9c359e72e603a4ccb329a","pageUrl":"https://welcome.whatever.com/?step=11","pageName":"Whatever | Create A Project"}

Form 2, app.whatever.com, with an email:

email: somefakeemail@intomato4.com
phone: +972 12-345-6789
firstname: Myname
lastname: Intomato4
company: Intomato4
photo: https://cdn.filestackcontent.com/1234
hs_persona: persona_1
hs_context: {"hutk":"9970c73472b9c359e72e603a4ccb329a","pageUrl":"https://app.whatever.com/welcome/company","pageName":""}

 

Both form submissions succeeded (HTTP 204). You will note both have proper hs_context.hutk value. However, two different contacts were created.

 

Interestingly, it seems like further Forms (different from the first two) submitted on app.whatever.com do deduplicate properly, but by that point there's always an email included.

 

This seems like a bug with deduplication using hutk, but I'm hoping it's just me doing something wrong.

 

Does anyone have any idea what is actually happening?

2 Accepted solutions

Accepted Solutions
IsaacTakushi
Solution
HubSpot Employee

Hi, @advance512.

 

I've shared the details of my investigation with Cooper, but here are the main points:

  • A valid email always takes precedence over a matching hutk value in determining which contact record will be updated.
  • The "first contact" was only identifiable with a hutk value.
  • The "second contact," with the email valuesomefakeemail@intomato4.com, was created by your custom app via the Contacts API just before the second form submission was ingested.
  • Since the Contacts API created the second contact with the email valuesomefakeemail@intomato4.com, the second form submission was associated with that record, making it appear that the two form submissions created separate records.

Isaac Takushi

Alumnus, HubSpot Developer Support

View solution in original post

advance512
Solution
Contributor

Just wanted to update I finally got this working.

 

Our issue is that we want the details of the Leads before knowing their email. So we submit a form with no email.

Then, we eventually find out their email after they register - but by that point we'd like to have a Contact created and accessible for work in the backend. So we can't wait for submitting another form in the frontend.

 

Unfortunately, the Contacts API does not support sending the hubspotutk identifying token when creating or updating a contact. So, we've had to use the forms API, which we have successfully. Then we call createOrUpdateContact() using the email as an identifier, to set other fields and manage the Contact as required.

 

However, it seems that because of timing issues, this then CREATES another Contact.. so deduplication fails again.

When we add a 3 second sleep between the Form submission and the Contact createOrUpdate() call, everything works just as expected.

 

This can be solved by allowing us to send hutk when creating or updating Contacts using the Contacts API.. or by us finding a way to work around making this call at all, until later on.

View solution in original post

5 Replies 5
IsaacTakushi
HubSpot Employee

Welcome, @advance512.

 

Apologies that your message was flagged as spam. I've found that large blocks of code trip this platform's filter.

 

I see that you have support ticket 2480480 open with my colleague Cooper. I'll work with him on the back end to find a solution for you!

Isaac Takushi

Alumnus, HubSpot Developer Support
0 Upvotes
IsaacTakushi
Solution
HubSpot Employee

Hi, @advance512.

 

I've shared the details of my investigation with Cooper, but here are the main points:

  • A valid email always takes precedence over a matching hutk value in determining which contact record will be updated.
  • The "first contact" was only identifiable with a hutk value.
  • The "second contact," with the email valuesomefakeemail@intomato4.com, was created by your custom app via the Contacts API just before the second form submission was ingested.
  • Since the Contacts API created the second contact with the email valuesomefakeemail@intomato4.com, the second form submission was associated with that record, making it appear that the two form submissions created separate records.

Isaac Takushi

Alumnus, HubSpot Developer Support

View solution in original post

advance512
Contributor

Hi Isaac,

 

Thank you! And kudos. I indeed discovered this issue about an hour ago. A team member created a Hubspot contact in the backend without me knowing. This indeed has causes the problem I encountered. I wanted to thoroughly verify it before posting here, but you've beaten me to it.

 

I will remark that I encountered two new issues when attempting to fix this:

1. First, while debugging, I noticed that the `hubspotutk` cookie does not always become accessible in all sub-domains, so that was my first direction to investigate. I created a thread about this:

https://community.hubspot.com/t5/APIs-Integrations/hubspotutk-cookie-and-sub-domains/m-p/271835#M246...

This was not the culprit, as even by forcing the hubspotutk to be set on the top level domain - this issue was not resolved.

2. Second, I thought that indeed it could have been a timing issue. This was when I asked our backend developer and found about the Contact creation. So what I attempted to do then was pass in the context.hutk (or hs_context.hutk, or just hutk or hubspotutk) value when creating the Contact, assuming they would then get linked. However, this apparently is not possible with the current API. I created a thread about it:

https://community.hubspot.com/t5/APIs-Integrations/Hubspotutk-and-Contacts-API/m-p/271824

 

Right now, what I'm trying to do is do two calls in the backend - 

a. First, submit a Form with the hutk and email address

b. Then, allow the contact to be created via the Contacts API

I am just hoping I won't run into timing issues here.

 

Thanks a lot!

advance512
Solution
Contributor

Just wanted to update I finally got this working.

 

Our issue is that we want the details of the Leads before knowing their email. So we submit a form with no email.

Then, we eventually find out their email after they register - but by that point we'd like to have a Contact created and accessible for work in the backend. So we can't wait for submitting another form in the frontend.

 

Unfortunately, the Contacts API does not support sending the hubspotutk identifying token when creating or updating a contact. So, we've had to use the forms API, which we have successfully. Then we call createOrUpdateContact() using the email as an identifier, to set other fields and manage the Contact as required.

 

However, it seems that because of timing issues, this then CREATES another Contact.. so deduplication fails again.

When we add a 3 second sleep between the Form submission and the Contact createOrUpdate() call, everything works just as expected.

 

This can be solved by allowing us to send hutk when creating or updating Contacts using the Contacts API.. or by us finding a way to work around making this call at all, until later on.

View solution in original post

IsaacTakushi
HubSpot Employee

Apologies for my delayed response, @advance512, but thank you for the insight.

 

I don't know of any plans to add hutk support to the Contacts API, but I will keep your use case in mind. If others find Alon's post helpful, please upvote and comment below.

Isaac Takushi

Alumnus, HubSpot Developer Support