HubSpot: Embed HubSpot forms in ion

If you’d like to embed HubSpot forms into your ion experiences, check out this post to easily repurpose your HubSpot embed code into a reusable ion widget. Taking these steps will enable you to redirect respondents to an ion page after form submission and to add ion rule logic to your HubSpot forms.

Before we begin

Before setting up a HubSpot form widget in ion, you will want to understand where to find your HubSpot portal ID and the form ID of the HubSpot form(s) you want to add to your ion pages.

Your HubSpot portal ID is a numeric value that is always present in the URL of every page within your HubSpot account. For example, when reviewing contacts in your HubSpot account, your URL should look something like the below. In this example, we’ve made the portal ID bold to make it easy to identify the portal ID.


You’ll also need to understand where to find your form IDs. The form ID is a longer alpha-numeric string that you will see in the URL when editing your HubSpot form or viewing form performance in HubSpot. Please find examples below of URLs you will see in your address bar when editing a HubSpot form or viewing performance with the form ID bold. 

Edit Form:


Form Performance:



Let’s get started

Now that you know where to find your HubSpot portal ID and form ID values, we can start working on the form widget in ion. You can put your portal ID and form ID values to the side for now until it’s time to add your HubSpot form widget to a page.

Add widget code to your ion library

The first step in ion is to add the below code to your ion Widget Library.

In ion, navigate to Libraries > Widgets and click the New widget button to add a new widget. We recommend labeling the widget something like Embed Form and storing it in a category called HubSpot. 

Next, paste the widget code below into the editor.

<script src=""></script>
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//"></script>
<script charset="utf-8" type="text/javascript" src="//"></script>
portalId: '##portalId',
formId: '##formId',
  onFormSubmitted: function($form) {
top.location.href = '##OnSubmittedUrl'

This code includes variables that you will be able to populate with your portal ID and form ID when the time comes to add it to your page. It also includes a variable that will allow you to specify what page to go to when the form is submitted.

Before saving, go ahead and set the Portal ID and Form ID as required text and Next Page as a required action, like the example below:

 Add the widget to your ion experience

Navigate to the page where you'd like to embed the HubSpot form. Drag the Widget icon from the Basics palette onto your page and select your new HubSpot > Embed Form widget. Next, under Variables in Creative studio, enter the portal ID and form ID, in the Source text option, from your HubSpot account and select the ion page you seek to redirect to.

Voila! Your HubSpot form is now embedded in your ion experience! You can even add ion rule logic to your HubSpot form.