Summary
Your Hubspot form on a landing page or web page can redirect visitors to a content track and de-anonymize them for PathFactory engagement reporting that can eventually be shared with Hubspot through the webhook integration.
This article covers:
- How to redirect form fills to a Content Track
Redirect Form Fills to a Content Track
- Create a form in Hubspot. This form will serve as the gate to your content track. Place this form on a landing page or web page using the embed code. Your embed will look something like this:
Example Hubspot Form Embed Code<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
hbspt.forms.create({
region: "na1",
portalId: "123456",
formId: "030a94da-6846-437d-9c7a-p47hf4c70r1"
});
</script> - Add the following script to the embedded code.
onFormSubmitted: function($form,data) {
var pathfactoryUrl = "<<Insert PathFactory Experience URL Here>>"
var redirectUrl = pathfactoryUrl + (pathfactoryUrl.indexOf("?") > -1 ? "&" : "?")
let email = data.submissionValues.email;
window.location = redirectUrl + 'lb_email=' + email ;
} - The final embed should 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: "123456",
formId: "030a94da-6846-437d-9c7a-p47hf4c70r1",
onFormSubmitted: function($form,data) {
var pathfactoryUrl = "<<Insert PathFactory Experience URL Here>>"
var redirectUrl = pathfactoryUrl + (pathfactoryUrl.indexOf("?") > -1 ? "&" : "?")
let email = data.submissionValues.email;
window.location = redirectUrl + 'lb_email=' + email ;
}
});
</script>
Test Form Redirect
Note:
|
Test to ensure this sequence of steps works as expected. |
- Render the Hubspot form created in Step 1 in your browser and fill it out.
- You should be redirected to your content track. Spend some time viewing the content in your track and thirty minutes after you close your session check back to PathFactory track analytics to see your session information assigned to an email.
Using a Hubspot Landing Page
Note: The Hubspot landing page should have only one form present on the page. Any additional forms on the page may cause the script to fail to execute.
NOTE: The Hubspot landing page should have only one form present on the page. Any additional forms on the page may cause the script to fail to execute.
- Go to the landing page and edit its Settings
- Select the Advanced settings and go to the Footer HTML section
- Enter the following in the Footer HTML section
<script> var pathfactoryUrl = "<<Insert PathFactory Experience URL Here>>" var redirectUrl = pathfactoryUrl + (pathfactoryUrl.indexOf("?") > -1 ? "&" : "?") window.addEventListener('message', event => { if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') { let email = event.data.data.submissionValues.email; window.location = redirectUrl + 'lb_email=' + email ; } }) </script>
- Publish or update the landing page.