APIs & Integrations

SJD38
Participant

Pulling cookie values into HubSpot forms on HubSpot landing pages

Hi all,

Looking for some advice/help on this issue as I've been unable to crack it and all the other posts in the forum are related to using the form embed code on outside pages. I'm looking to load cookie data into hidden form fields on an HS form on an HS landing page. The cookies are set and loaded correctly on the LP, as far as I can tell, but the form does not pick up on the matching cookie values.

Is it the case that using the form selector on the LP builder (which uses an iframe) is simply not a viable way to do this and would need to use the raw embed code? Is there something else I'm missing here?

Thanks for any input!

0 Upvotes
8 Replies 8
SJD38
Participant

Pulling cookie values into HubSpot forms on HubSpot landing pages

Thanks @tjoyce - Ultimate goal here is to be able to store UTMs (& other params) when someone lands on our site the first time but *doesn't* convert until later or on a separate page (the linked LP, for example). We want to have the UTMs still captured on that form completion as contact properties. If there's a better way to achieve this with what Hubspot already provides, I'd appreciate any direction you could give me there.

0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling cookie values into HubSpot forms on HubSpot landing pages

@dennisedson - can you chime in here about the UTMs?

@SJD38 - You have tried to name the form fields exactly as the url parameters in the url? Say, for instance putting ?first_name=SJD38 would automatically populate the first_name field in a hubspot form. 

0 Upvotes
SJD38
Participant

Pulling cookie values into HubSpot forms on HubSpot landing pages

@tjoyce - My understanding is that that works if the visitor lands on a page with UTMs and the form is on said page, but doesn't work if their landing page doesn't have a form on it. The problem we're trying to solve here is how to preserve the UTMs when they first hit the site and then send to form when they finally convert later, on a different page. In looking for a solution, I saw suggestions that the hidden form fields (with matching names) would also be able to pull in cookie values but all of the solutions I can find speak to modifying the raw form embed code to make this work. I'm seeking a solution that would allow these values to be pulled into hidden fields in a form that is added to a HS landing page via the form selector, or confirm that the *only* way to do this is via raw embed code (in which case we'll look into a workaround on styling and layout).

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Pulling cookie values into HubSpot forms on HubSpot landing pages

The best approach would be with the raw form embed code, but you might be able to get away with something like this

window.addEventListener('message', event => {
   if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
       // the form is ready to manipulate!
   }
});
0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling cookie values into HubSpot forms on HubSpot landing pages

@SJD38 - Interesting that you are seeing the iframe for the embed on your internal pages. 

Can you link us to the page and tell us which fields you are trying to connect to the cookie?

SJD38
Participant

Pulling cookie values into HubSpot forms on HubSpot landing pages

Hi @tjoyce - Thanks for your help. Example page in question here: https://go.hivebrite.com/us-higher-ed-demo-booking

Trying to capture utm_medium, utm_source, utm_campaign, utm_term as hidden fields via cookie. As mentioned, the script to set and call them is working fine but the form isn't picking them up and I'm at a loss for why.

0 Upvotes
tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pulling cookie values into HubSpot forms on HubSpot landing pages

Hi @SJD38 - I think this seems a bit off to capture analytics data this way... What are you ultimately trying to accomplish?

dennisedson
HubSpot Product Team
HubSpot Product Team

Pulling cookie values into HubSpot forms on HubSpot landing pages

Hey @SJD38 

I have a feeling you are on the right track. 

@tjoyce... For some reason I always call you for forms questions.  I wonder why  🤔😉

What are your thoughts?