JavaScript Library Iframe Form Prefilling

In this guide, we’ll cover how to prefill form data such as first name, organization, etc.

Overview

At times you may already know some of your customer’s information such as first and last name, email address, or other information. Rather than asking the user to enter this data into the SheerID Verification Form again, you can prefill fields. This makes it easier and faster for your customer to fill in the form and proceed, resulting in higher conversion rates.

Installation

There are a few different ways to install SheerID’s form on your web page. This tutorial applies to Inline iframe and Modal install methods.

See Publish Program for more information on the different installation techniques.

Inline iframe

Prefilling form data using the Inline iframe installation method

<div id="my-container"></div>
<script>
  // sheerId.loadInlineIframe returns an object which can be assigned to a variable such as `myFrame`
  const myFrame = sheerId.loadInlineIframe(
    document.getElementById('my-container'),
    'https://services.sheerid.com/verify/YOUR_PROGRAM_ID/',
  );
  // Now you can call `setViewModel()` and specify all or part of a viewModel object:
  myFrame.setViewModel({
    firstName: "Jane",
    lastName: "Doe",
  });
</script>

See a live example here.

Prefilling form data using the Load In Modal installation method.

<a onclick="displayVerification()">Confirm Eligibility</a>
<script>
  function displayVerification() {
    // sheerId.loadInModal returns an object which can be assigned to a variable such as `myFrame`
    const myFrame = sheerId.loadInModal(
    'https://services.sheerid.com/verify/YOUR_PROGRAM_ID/', {
      mobileRedirect: false,
    });
      // Now you can call `setViewModel()` and specify all or part of a viewModel object:
    myFrame.setViewModel({
      firstName: "Jane",
      lastName: "Doe",
    });
  }
</script>

See a live example here.

View Models

The fields you can provide will vary based on your Program’s Segment (e.g. student, teacher, etc) and sometimes based on features you may have enabled.

Search the JS Library Reference for “ViewModel” to find more detailed information on the various viewModels (and fields) that are possible.