Associate Contact Creation with hubspotutk cookie for traffic sources


Our main website has hubspot tracking setup, and hubspotutk cookies are properly created when visiting that site. When a potential customer clicks on a link to to create a new account through our software (different site), I pass the hubspotutk cookie through the link to the other site. In the backend we use this cookie in the POST request to hubspot for our form. The form information appears to fill in just fine, but the hubspotutk doesn't seem to be properly associated since we always get X was created from Direct Traffic from No URL .

I have read varying ways to supply this depending on the situation (hs_context/context). I believe the latter is correct, but I've tried them both with no success.

The data is sent in the following format:

'email': ;,
'context': {
'hutk': self.hubspotutk,
'pageUri': '',
'ipAddress': '',
'pageName': 'Sample',
'firstname': self.firstname,
'lastname': self.lastname,
'lifecyclestage': self.lifecyclestage,
'key_contact': self.key_contact


Hey, @_patrick!

I suspect we may be dealing with some cross-domain cookie shenanigans. Happy to help investigate. Would you mind clarifying the following?

  1. What is your Hub ID?
  2. What is your main website's domain?
  3. Exactly what action(s) do they take to reach your account site?
  4. What is your account site's domain?
  5. What do you mean by "I pass the hubspotutk cookie through the link to the other site." Which direction is the cookie going and how are you passing it? Are you using the __hsfp , __hssc , and __hstc parameters described here?
  6. Are your visitors at any point moving from a secure HTTPS domain to an insecure HTTP domain?
  7. Are you using the v3 Forms API endpoint? If so, you will indeed use JSON and the context object (as opposed to hs_context, which is used for the v2 endpoint).
  8. Can you provide links to some example contacts showing this behavior?


Thanks for the reply, @Isaac_Takushi

I hope this answers all those questions effectively:

  1. 4525761
  3. There are several buttons that will redirect to the application where they can make an account.
  5. On the main website, we provide the hubspot cookie in the url redirect like this:
  6. It's all over HTTPS
  7. I am using v2, although I did try hs_context before (also can you pass just the cookie itself in there?).


Here's a contact I made today

When making this contact, I changed the data in my first post so that context is now hs_context.


Hey, @_patrick.

Thanks for that information! A few things jump out to me.

  • The Hub ID you provided (4525761) is your developer test account while your production account is 3411792.
  • The tracking code for account 3411792 is installed and firing on but not on
  • The tracking code for account 4525761 is missing on both and
  • You are creating contacts in the developer test account 4525761 but the tracking code on your site is tied to your production account, 3411792. As a result, no contact created in the test account will be properly tracked. Even though the hutk token value is present, it shouldn't mean anything to account 4525761.
  • This contact's form submission data, visible here, shows that you're trying to pass hutk as a property value. On the back end, however, I see that it was not passed properly in the meta data array. This is all that shows:
"meta-data" : [
"name" : "requestIpAddress",
"value" : ""
"name" : "apiContextMissing",
"value" : "ipAddressNotSupplied"
"name" : "endpointType",
"value" : "LEGACY_UPLOAD"
"name" : "serverRegion",
"value" : "us-east-1"

If you're using the v2 Forms API endpoint, make sure that the hs_context parameter is JSON-formatted and URL encoded. For example:



Thanks for this info @Isaac_Takushi. I just recently assumed all the Hubspot things so am still figuring out the existing infrastructure put in place.

I had just realized this issue with hubspot IDs and have created an account using the non-developer Hub ID:

It still doesn't have the proper tracking, but as you said I probably need to fix how the utk is being passed.

I have a few questions though:

  • I don't need 3411792 to be on if all the hubspot requests are made using the forms API, right? If I first associate the contact creation with the utk and then use the email from there on out it should be ok?

  • Is there a way I can easily generate hubspotutk cookie value to test the account creation using our developer Hubspot ID?


Hey, @_patrick.

That contact has since been deleted. Would you mind sharing another one? I'd like to check the form submission JSON to verify whether the hutk was passed in the correct object.

Regarding your questions:

  • If you don't need tracking data from, then I suppose you don't need to install the 3411792 tracking code. As long as the hutk value is passed correctly, the new contact's Original Source value will reflect how they first reached but the form submission won't properly reflect the page it was submitted on and the contact won't show any browsing activity on
  • With your second question, I think you're getting at the fact that your production account's tracking code is already on so you can't reliably test the developer account's tracking code there, right? I don't know of any way to generate a hubsoptutk cookie token value without installing first the desired tracking code on a page, so perhaps you could place the 4525761 tracking code on just to test whether you can get any tracking data into HubSpot?


Hi @Isaac_Takushi,

I've since upgraded to the v3 api and have had success creating contacts, companies, and linking the two. However, I am experiencing some inconsistency with this process.

The general approach is:

  1. Create a contact through form submission:
  2. Verify the contact by id using a separate request:
  3. Create a company:
  4. Associate the company and contact:

I'm experiencing issues in 2 places:

  1. When I verify a contact (step 2), sometimes the request fails to verify, and although the response indicates the contact could not be found, it is there when I check on Hubspot.
  2. When I try to associate a contact with the new company (step 4), sometimes the request fails with a 404. Both company and contact exist on Hubspot when I check.

Both of these issues only occur sometimes, so I'm thinking that I'm verifying the contact before it's fully set up in Hubspot or trying to associate the contact with the company before both are fully set up.

Is this a common issue? Do you just tell customers to wait between dependent steps?


Hey, @_patrick.

I'm glad to hear that you're having success with the v3 Forms API endpoint!

Your theory is spot on. This kind of behavior almost always indicates that the contact or company hasn't finished processing by the time you try to retrieve it or associate it. If you add a delay of a second or two, that's usually enough.

Here are some related topics: