1. Home
  2. Forms
  3. Hubspot Forms
  4. Using a Content Track as a Hubspot Form Confirmation Page

Using a Content Track as a Hubspot Form Confirmation Page

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

Scenario:

  • You have a Hubspot Form
  • You want to send visitors who fill out the form to a Content Track rather than a static Thank You page
  • You want those PathFactory visitor activities to be tracked and the data to be sent to Hubspot

Redirect Form Fills to a Content Track

  1. 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>
  2. 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 ;
    }
     
  3. 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.
  1. Render the Hubspot form created in Step 1 in your browser and fill it out.
  2. 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.

    For Example
    I filled out a Hubspot form that redirected me to my 2019 NBA Champions content track and spent some time viewing a few assets. I can see my engagement data in PathFactory assigned to the email I used in my Hubspot form submission (tara@pathfactory.com).

    Engagement data for this session also appears in Hubspot on the contact record of the visitor. You should see this data in the contact properties for the visitor that filled out the form.
    imageExample of a Hubspot form result


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.

  1. Go to the landing page and edit its Settings
  2. Select the Advanced settings and go to the Footer HTML section
  3. 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>
  1. Publish or update the landing page.
Updated on January 25, 2024

Was this article helpful?

Need Support?
Can't find the answer you're looking for? Don't worry we're here to help!
CONTACT SUPPORT