API Integration: Custom form with contact tracking issue

contacts

#1

Hi all,

Please bare with me as I am new to the HubSpot world. I am trying to create a custom form to integrate with HubSpot. When a user submits the form, a contact record should be created and a cookie should be set so that all page views are tracked. This works perfectly with the stock HubSpot form embed; however, I have some custom features that need to be implemented which require a custom form integration.

Here’s what I’ve tried:

I have created a form in HubSpot and am generating the form on my website using the forms/v2/fields/ endpoint.

Submissions are handled through a standard form post and data is sent to the forms/v2/portal/id endpoint, a 204 is sent as the successful response code. From my understanding, a contact record is created or updated at this point.

Here’s where it is different from the standard embed:

If I do a contacts/v1/contact/utk/cookie/profile lookup on contacts created on a standard embed, the is-contact flag is shown as true. But, when I do the same lookup on a contact created with my custom form, the is-contact flag is empty. To me, it seems like the form submission endpoint should be returning cookies for me to set – that is obviously not the case though.

Where do I go from here? How can I ensure that the proper tracking cookie is set, and all page views are tracked?


#2

@wd001 Do you have the HubSpot tracking code installed on that page or your site? The form itself does not deploy a cookie. That should be done by the tracking code before anyone submits on a form. Then you pass the cookie data along with the form submission to HubSpot.


#3

Yes, I have a tracking code installed on the site. You’re saying that the cookie that is sent with the form submission endpoint is used for tracking purposes, correct?

I believe I have the cookie being sent properly to the endpoint, but I will do some further testing with that and report back.


#4

@wd001 Yes there is just one cookie that is used for tracking. That cookie will get dispersed by the tracking code and not by the form submission. If a user goes to you page directly, on load they should be cookied before they even fill out the form.