Developers

Prefilling visitor details

Hand off what you already know about the visitor — from your forms or your auth — so the pre-chat form fills itself.

Why prefill

If you already know who the visitor is — because they filled out a form, or they're logged in — you can pass that straight to the widget so they don't have to type it again. Matching fields are pre-populated, and if every required field is already filled the pre-chat form is skipped entirely.

The common case: hand off a form submission

A visitor enters their email in your own page's form; when they open chat, it's already there:

<form id="lead-form">
  <input type="email" name="email" required />
  <button type="submit">Talk to us</button>
</form>

<script src="https://api.glimpze.io/functions/v1/widget-loader?id=YOUR_WIDGET_ID&mode=api" async defer></script>
<script>
  document.getElementById('lead-form').addEventListener('submit', (event) => {
    event.preventDefault();
    const email = event.target.elements.email.value;

    // Prefill, then open the widget straight into chat.
    GlimpzeWidget.open({ prefillFields: { email } });
  });
</script>

Set defaults once for the whole page

If you know the visitor at page load (e.g. a signed-in user), set the values once with configure(). Every later open() reuses them.

GlimpzeWidget.configure({
  prefillFields: {
    name: currentUser.fullName,
    email: currentUser.email,
    plan: currentUser.plan,        // a custom field
  },
});

How prefillFields maps to your form

prefillFields is a flat object keyed by your field names — the same names returned by getFields(). Two names are special:

KeyGoes toNotes
nameVisitor identityMust be a string.
emailVisitor identityMust be a string.
anything elseVisitor custom dataPrefills the form field whose name matches; also stored as visitor metadata.
GlimpzeWidget.open({
  prefillFields: {
    name: 'Jane Doe',
    email: 'jane@acme.com',
    company: 'Acme Inc',   // matches a "company" form field
    plan: 'enterprise',    // matches a "plan" form field
  },
});

Keys that don't match any field still get stored as visitor custom data, and the SDK logs a console.warn listing the valid field names — handy for catching typos. Use getFields() to discover exactly which fields a widget has.

Good to know

Prefilled values are a convenience, not proof of identity. The visitor can still edit a prefilled field, and Glimpze never treats a prefilled email as verified. Don't rely on it for authentication.
visitorInfo / customData still work. prefillFields is sugar over the two lower-level keys. visitorInfo: { name, email } and customData: { ... } are still accepted and take precedence if you pass both.