APIs & Integrations

alexander_sloan
Participant

Linking HubSpot's trakcking to new contacts

SOLVE

I want to be able to associate HubSpot's anonymous browsing data with Contacts created from the server.


HubSpot collects anonymous browising data which allows you to track where new leads/contacts came from. The unique ID for that appears to be hubspotutk in the cookies.

 

We can't run HubSpot's identify on the clientside and therefore we create new contacts using the server side SDK (node.js) whenever someone signs up. I want to associate these two things so that we get the all the marketing/funnnel info inside HubSpot.


Ideally we would just add hubspotutk as a property the to the contact create call we're already making, but that doesn't seem to be an option. Is there another way to accomplish the same thing?

0 Upvotes
1 Accepted solution
alexander_sloan
Solution
Participant

Linking HubSpot's trakcking to new contacts

SOLVE

Ended up submitting a custom form event from the server in order to create the Contact Submit data for a form (Supporting Authentication) | Forms API So the flow is:


1. Grab the hubspotutk from the cookies

2. Check wether a contact with the hubspotutk already exists (data.is-token) at /contacts/v1/contact/utk/${hubspotutk}/profile.

3. If not a Contact, send a request to the above Forms API:

 

data: {
fields: [
{
objectTypeId: "0-1",
name: "email",
value: email
}
],
context: {
hutk: hubspotutk
}
}

 

 

4. Now that the Contact exists, you can update as normal.

View solution in original post

0 Upvotes
4 Replies 4
alexander_sloan
Solution
Participant

Linking HubSpot's trakcking to new contacts

SOLVE

Ended up submitting a custom form event from the server in order to create the Contact Submit data for a form (Supporting Authentication) | Forms API So the flow is:


1. Grab the hubspotutk from the cookies

2. Check wether a contact with the hubspotutk already exists (data.is-token) at /contacts/v1/contact/utk/${hubspotutk}/profile.

3. If not a Contact, send a request to the above Forms API:

 

data: {
fields: [
{
objectTypeId: "0-1",
name: "email",
value: email
}
],
context: {
hutk: hubspotutk
}
}

 

 

4. Now that the Contact exists, you can update as normal.

0 Upvotes
cooperelias
Contributor

Linking HubSpot's trakcking to new contacts

SOLVE

I believe you can only accomplish this with Marketing Hub Enterprise using the option to Track a Custom Behavioral Event using the POST/events/v3/send endpoint and including the utk and email as part of the body parameters.

 

I have been able to successfully run that with a server-side process when I have both the hubspotutk and the contact's email address, and it will create the contact associated to that anonymous visitor profile.

 

My full process is this:

  1. Search for an existing contact with the email address.
  2. Get a contact by its user token using that legacy endpoint. I do that to check and see if that hubspotutk is associated to an existing contact with a different email address already.
  3. Send Custom Behavioral Event with both the utk and email parameters included in the body.
alexander_sloan
Participant

Linking HubSpot's trakcking to new contacts

SOLVE

Didn't clock that that API is only available on Enterprise. Still seems like a better solution that where we ended, but the hint about looking up Contacts with the existing hubspotuk was 👌

0 Upvotes
alexander_sloan
Participant

Linking HubSpot's trakcking to new contacts

SOLVE

Thanks! That makes sense (though so convoluted, urgh). Will give it a go and report back.

0 Upvotes