Hi,
Hope this is the right place for this question.
I want to create a dynamic url from properties from a form; like firstname, lastname and email.
I can do it with an email like this link: Create a Dynamic URL using Hubspot CRM - Growthrobotics
But not from a form.. it does not read the properties or something.. We use something like this:
https://company.com/SelfRegister/fn={{contact.firstname}}&ln={{contact.lastname}}&em={{contact.email}}&Revisit=True
But it does not save the contact firstname, lastname and email…
The link goes to a external site where the visitor can do a test and the result is sent to them to the email adres they fill in in the form.
Can anyone help? hope i made the question clear enouh
Teun
October 1, 2021, 12:55pm
2
Hi @Jelmert ,
Do you want to redirect the user to the external site as soon as the user submits the form?
If that is the case, you need to customize the form embed code . Use the onFormSubmitted callback to generate your URL using JavaScript or jQuery.
Your code could look something like this:
hbspt.forms.create({
portalId: '',
formId: '',
onFormSubmitted: function ($form) {
window.location.href = `https://company.com/SelfRegister/fn=${$('input[name="firstname"]').val()}&ln=${$('input[name="lastname"]').val()}`
}
});
Hi @Teun ,
Thanks for this! We will try this.
We do want to redirect them as soon as they fill in the form. Think this could work.
Hi @Teun
Could you please explain where we should edit the form embed code? The link only shows how to edit it.
Do we need to create a custom form module? Or can we edit the embed code in the formsmenu?
(The form will be located on a hubspotpage and linked to an external webpage)
Teun
October 5, 2021, 5:41pm
5
Hi @Jelmert ,
Create a custom module, it should at least have a ‘form’ field . Your code could look something like this:
<div class="c-form" id="js-form-module" data-portal_id="{{hub_id}}"
data-form_id="{{module.form.form_id}}">
<script>
var container = document.getElementById('js-form-module');
if (container) {
var portalId = container.dataset.portal_id;
var formId = container.dataset.form_id;
hbspt.forms.create({
portalId: portalId,
formId: formId,
cssRequired: '',
onFormSubmitted: function ($form) {
window.location.href = `https://company.com/SelfRegister/fn=${$('input[name="firstname"]').val()}&ln=${$('input[name="lastname"]').val()}`
}
});
}
</script>
</div>