How to Pre-Fill a HubSpot Form for a More User-Friendly Experience

Learn step-by-step how to pre-fill a HubSpot form to enhance user experience and boost conversion rates. We cover two effective methods: using HubSpot's native functionality and custom JavaScript.

How to Pre-Fill a HubSpot Form for a More User-Friendly Experience
Do not index
Do not index

Introduction

HubSpot is a powerful inbound marketing, sales, and customer service platform that offers a variety of tools to help businesses grow. One of the fundamental tools it offers is the ability to create and manage forms. Forms serve as the gateway between your company and new leads, helping you gather essential information you can use to tailor your future interactions.
However, in certain scenarios, pre-filling a HubSpot form can provide a more seamless, user-friendly experience for your website visitors. For example, pre-filling can help reduce the amount of time and effort it takes for a returning visitor to complete a form, thereby increasing conversion rates.
In this blog post, we'll walk you through the steps to pre-fill a HubSpot form using two methods: HubSpot's native functionality and custom JavaScript code.

Method 1: Using HubSpot's Native Functionality

Requirements:

  • A HubSpot account
  • An existing HubSpot form
  • Basic familiarity with the HubSpot dashboard

Steps:

  1. Login to HubSpot: Navigate to your HubSpot dashboard and login to your account.
  1. Go to Marketing > Lead Capture > Forms: From your dashboard, navigate to the Forms section under the Marketing tab.
    1. notion image
       
  1. Select Your Form: Choose the form that you would like to pre-fill.
  1. Enable Pre-fill Features: Unfortunately, as of my last update in September 2021, HubSpot does not have a direct native option to pre-fill forms with user data. However, HubSpot forms do remember user data across sessions when cookies are enabled, effectively pre-filling forms based on previous submissions. This is useful for repeat visitors but doesn't cover all pre-filling needs.
    1. notion image
       

Method 2: Using Custom JavaScript

Requirements:

  • Basic knowledge of HTML, JavaScript, and jQuery
  • A HubSpot form embedded in your website

Steps:

  1. Add jQuery to Your Site: If you haven't already, add jQuery to your website by inserting the following script tag into the <head> section of your HTML:
    1. <script src="<https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js>"></script>
      
  1. Identify Form Fields: Each field in a HubSpot form has a unique name or ID. Use browser Developer Tools to identify these.
  1. Write Your JavaScript Code: Write a custom JavaScript function to pre-fill these fields. Below is an example that pre-fills a text field and an email field:
    1. $(document).ready(function() {
        // Replace 'form_id' with your HubSpot form ID
        $('form#form_id').each(function() {
          // Pre-fill the name field
          $(this).find('input[name="name"]').val('John Doe');
          // Pre-fill the email field
          $(this).find('input[name="email"]').val('johndoe@example.com');
        });
      });
      
  1. Include the JavaScript in Your HTML: Place this JavaScript code within <script> tags either in the <head> section of your HTML or right before the closing </body> tag.
  1. Test the Form: After implementing the code, test the form to ensure that the pre-filling is working as expected.

Conclusion

Pre-filling a HubSpot form can greatly enhance the user experience and possibly increase your conversion rates. While HubSpot's native functionalities do offer some level of form pre-filling for returning users, a more customized approach can be achieved by using a small amount of JavaScript code. Both methods have their own merits, and the best choice will depend on your specific needs and the technical expertise available to you.
Happy form-filling!

Upgrade your form builder

Try Fillout, the modern form builder. Collect 1000 submissions/month for free.

Sign up for free
Dominic Whyte

Written by

Dominic Whyte

Dominic is the co-founder of Fillout.com. He previously worked on engineering & product at Retool. Prior to Retool, he started Cheer ( acquired by Retool in 2020).