HubSpot: Get data via HubSpot REST API

You can leverage Ion’s Get Lead integration with the HubSpot REST API to optimize your Ion experiences. This integration enables you to retrieve data from HubSpot based on a respondent's email address. You can leverage Get Lead to pre-populate (or shorten) Ion forms, auto-segment respondents and for progressive profiling.

This document provides step-by-step instructions to set up a REST API integration with HubSpot to get lead data. We’ll use the integration to pre-populate an Ion form in this document, but, as noted, there are a few different ways you can use Get Lead to enhance your ion experiences.

Before we begin

There are few items you'll need to have ready in Ion prior to setting up the integration, listed below:

Check out the "Before you begin" support post for guidance in creating these items.

  • Create data collection fields that will store HubSpot data
  • Create Ion form(s)
  • Set-up testing creative

Let’s Get Started!

1.  Add HubSpot account credentials to Ion

  1. Click the Integrations tab in your Ion console’s side nav
  2. Click “Set up account credentials” toward the top of the screen
  3. Under "HubSpot", click “New HubSpot credential”
  4. Add a friendly label for your account
  5. Save
  6. You will be redirected to HubSpot to authenticate your credentials
  7. After signing into HubSpot, click the Grant access button to allow the Ion platform to access your HubSpot account
  8. After granting access, you will be returned to your Ion console.

2. Create field mapping

Taking the steps below will enable you to extend an email address value to HubSpot and map the data points returned to their corresponding ion data collection fields. To get started, add your new field mapping:

  1. Navigate back to the Integrations screen
  2. Click the green “New field mapping” button
  3. Label the field mapping and optionally add a description
  4. From the Integration type menu, select “HubSpot”
  5. Save

3. Add Email Address as the Outbound field

The email address value will be used as the key to retrieve data from HubSpot.

  1. Click the green “New outbound field” button
  2. Select the Data field from the Source drop-down
  3. Select Contact Info > Email Address
  4. Make the field required for the integration to run
  5. Select the corresponding HubSpot Email Address field
  6. Save 

4. Create Inbound fields

Inbound fields will map the data HubSpot returns into their corresponding Ion data collection fields.

  1. Click the green “New inbound field” button
  2. From the Target dropdown menus, select the Ion data collection field you seek to populate with HubSpot data
    • To pre-populate Ion forms with HubSpot data, be sure to select the data collection field used on your form
  3. From the Source dropdown, select the HubSpot field you want to pull data from
    • OR, select Javascript code if you want to transform the HubSpot data prior to storing it in ion data collection
    • Use responseBody.hubspot_field_name to access the HubSpot field via Javascript
  4. Save
  5. Repeat these steps for each HubSpot data field you seek to save into ion data collection

5. Create integration

  1. Navigate back to the Integrations screen
  2. Click into the Integrations tab
  3. Click the green “New integration” button
  4. Enter label
  5. Optionally add a description
  6. Select the Field Mapping you’ve just created
  7. Skip Maximum retries
  8. Select Get Lead as the API method
  9. Select the outbound Email Address field
  10. Optionally add yourself to the debug distribution list for testing
    • This will deliver an email to the designated address when the integration runs that displays the request and response from HubSpot
    • Check Only send error emails if you want to receive the debug email only when there is an error

6. Add integration to ion pages

The Ion platform runs the integration based on the rules you create. For HubSpot Get Lead, the rule will typically run the integration at the page-level of the landing page. You can, however, run the integration on any actionable step in your Ion experience. The steps below walk through adding the rule at the page-level to populate an ion form with HubSpot data.

  1. Navigate into the testing creative with a form that you set up prior to beginning the integration steps
  2. Under the Page tab in creative studio, click on +RULES
  3. Add the following rule:
    • Condition: No conditions required
    • Action: Run integration (select HubSpot Get Lead integration)
  4. Save

7. Test integration

Please note, integrations do not run in Preview Mode, so you'll want to open a URL for your testing creative. Either pass an email address into your Ion page on the query string or submit your initial form that collects the email address. If passing an email address into Ion on the query string, be sure that the parameter name you append to the URL matches the "data name" of the Ion data collection field selected as the outbound field in your Field Mapping.

Once the integration runs, the form you seek to pre-populate will display the data retrieved from HubSpot. If you’re on the debug email distribution list, you’ll receive an email that displays the request and response from HubSpot.

Nice work!

Once you’ve completed these steps, your integration is ready for use. You can add the rule to run the integration on all applicable creatives.

As noted, HubSpot Get Lead can be used to accomplish other objectives. Here are some examples that can be accomplished using this integration and ion's Rules engine:

  • Shorten or replace forms
  • Auto-segment respondents
  • Build progressive profiles
  • Serve-up dynamic content based on HubSpot data

Feel free to reach out to our Support team for assistance in leveraging this integration.