CMS Development

polarlight
Miembro

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

I have created a very simple standard Hubspot form that has a single standard field - the field is used for the user to enter an email address.

 

I've created a template page that includes that Hubspot form and the template page also has some very simple Hubl code that will use the input email address to lookup the Contact information associated with that email address and then extracts a custom Contact property that has a unique URL for the person to click on that will take them to an external page.

 

I have the simple Hubl code working just fine - I can hardcode a specific Contact object, extract that custom Contact property and then show the user the unique URL, like this:

 

Hi, {{ contact.firstname }} {{ contact.lastname }} - to start your online tutoring session, click
<a href="{{ contact.groupworld_link }}" target="_blank">here</a> at any time!

 

The only problem I have is HOW to access the email address from that standard Hubspot form that is on the same page, where the only field in the form is where the user enters their email address.

 

BTW, I even tried to alternatively EMBED the Hubspot form by doing this (based on one article that I found):

 

{% form "my_form" form_to_use='8ba4d617-f98d-4415-94e9-5f2e518da3d9', title='My Form' %}

 

And then, after entering in some email address, I thought I could then access the email address that was entered in the embedded form by doing something like this:

 

my_form.email = {{ my_form.email }}

 

But alas, that seemingly obvious method of trying to access the embedded form data did NOT work as I hoped ...

 

Note that after the email address is entered by the user, I just get the standard "Thanks for submitting the form." and the form disappears (as expected) - but it's not clear how the Hubl code on that same page can then get the email address that was entered on the standard Hubspot form.

 

I've looked through the documentation and don't see anything that addresses this simple use case - I know it can be done ... I'm clearly just missing something - and yes, I'm a total newbie when it comes to Hubspot and Hubl, but I'm an experienced software engineer - so once somebody can point me to an example of someone doing anything similar to what I'm trying to do, I'll be able to get my simple use case working properly.

 

Thank you in advance for any help and/or advice!

0 Me gusta
1 Soluciones aceptada
MikeCormack
Solución
Colaborador líder

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

yes, as long as you aren't trying to run workflows or update stuff then that should work, using personalised fields on a page disables the cache so it should load as expected.

 

Previously I had problems with trying to update things using smart content, as people will not get added to a list as fast as they get the new page. FYI.

 

you can redirect the form sub either in the form options (gloabl control) or the page itself

Ver la solución en mensaje original publicado

4 Respuestas 4
MikeCormack
Colaborador líder

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

hubl is server side processing, so you cant access things on a page that has already loaded.

 

You need to load a new page.

0 Me gusta
polarlight
Miembro

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

Hi Mike,

 

Thank you for pointing that out - so, assuming I have redirected to a new page (I don't know how that is done yet, but I'll figure it out) - then at that point, I'm guessing that the Hubl code would just pick off the email address by accessing a query parm that was attached to the redirect page - does that sound about right?

 

Thanks,

Steve

0 Me gusta
MikeCormack
Solución
Colaborador líder

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

yes, as long as you aren't trying to run workflows or update stuff then that should work, using personalised fields on a page disables the cache so it should load as expected.

 

Previously I had problems with trying to update things using smart content, as people will not get added to a list as fast as they get the new page. FYI.

 

you can redirect the form sub either in the form options (gloabl control) or the page itself

polarlight
Miembro

How do I access Hubspot form data in my Hubl code after the form is submitted?

resolver

Hi Mike,

 

Thanks again for that confirmation of what I suspected, as well as the additional thoughts and information.

 

Fortunately, I won't be trying to run workflows or update anything - I'm just interested in grabbing that one URL property from the Contact record that matches the email address and providing the user with a link that brings up that external URL in a new tab - simple and straight-forward.

 

Thanks again!

Steve

0 Me gusta