Passing a hidden email value field from Hubspot Form to a thank you page

SOLVE
Highlighted
New Contributor

I am looking for way to customize a form to pass the email field value onto a thank you page for tracking purposes after the form is submitted.

 

Using this form embed code to customize:

 

hbspt.forms.create({
portalId: '',
formId: '',
onFormSubmit: function($form) {
// YOUR SCRIPT HERE 
}
});

 

Currently when I hit submit on the form my thank you page url is not receiving the value and just shows email= {{contact.email}} instead of the actual email.

 

Please advise

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Community Manager

Hi @jferrerpmc,

 

Happy to point you to similar discussion here!

 

If the first page that you're redirecting the form is built on HubSpot CMS, you can check out this thread here: https://community.hubspot.com/t5/APIs-Integrations/Pass-field-value-to-URL-parameter/m-p/240551 - The latest post by John has the solution to this issue.

 

If it's not built on HubSpot CMS, you mayw ant to check out this discussion: https://community.hubspot.com/t5/APIs-Integrations/Include-form-fields-as-redirect-URL-parameters-on... where Derek Cavaliero outlined the possible solution - by using the following code:

    onFormSubmit: function($form){
        setTimeout( function() {
            var formData = $form.serialize();
            window.location = "http://www.yoururl.com?" + formData;
        }, 250 ); // Redirects to url with query string data from form fields after 250 milliseconds.
    }
Reply
0 Upvotes
2 Replies 2
Community Manager

Hi @jferrerpmc,

 

Happy to point you to similar discussion here!

 

If the first page that you're redirecting the form is built on HubSpot CMS, you can check out this thread here: https://community.hubspot.com/t5/APIs-Integrations/Pass-field-value-to-URL-parameter/m-p/240551 - The latest post by John has the solution to this issue.

 

If it's not built on HubSpot CMS, you mayw ant to check out this discussion: https://community.hubspot.com/t5/APIs-Integrations/Include-form-fields-as-redirect-URL-parameters-on... where Derek Cavaliero outlined the possible solution - by using the following code:

    onFormSubmit: function($form){
        setTimeout( function() {
            var formData = $form.serialize();
            window.location = "http://www.yoururl.com?" + formData;
        }, 250 ); // Redirects to url with query string data from form fields after 250 milliseconds.
    }
Reply
0 Upvotes
New Contributor

Thank you, this is very helpful! 

Reply
0 Upvotes