Hi All, long shot. We are trying to replace our current forms with a HubSpot form, but the blocking issue is we need to create a Rudderstack track event that fires upon from submisssion. Has anyone done this before? While HubSpot is a Source in Rudderstack, it only allows you to send data to a data warehouse.
Hi @TDearlove6,
if you’re embedding the HubSpot forms on a “non-HubSpot-page” you can modify the form-embed code with a onFormSubmit action and trigger the Rudderstack tracking event.
Here’s a quick example:
The default form-embed code looks like this
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
hbspt.forms.create({
region: "na1",
portalId: "XXX",
formId: "XXXXXX-XXXXXX-XXXXXXXX"
});
</script>
with a onFormSubmit addition it would look like this
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
hbspt.forms.create({
region: "na1",
portalId: "XXX",
formId: "XXXXXX-XXXXXX-XXXXXXXX",
onFormSubmit:{
//your Rudderstack tracking action
}
});
</script>
hope that helps,
best,
Anton