Skip to content

Embed forms anywhere

JavaScript API

Open popups, listen for events, control embeds programmatically.

On this page

Once the SDK loads, window.Maxforms is a function you call with a command and arguments. All calls are safe to make before the SDK finishes loading — they queue and replay automatically.

1. openPopup#

Maxforms('openPopup', {
  formId: 'YOUR_FORM_CODE',
  position: 'center',        // 'center' | 'bottom-right'
  width: 560,
  overlay: true,
  hideOnSubmit: true,
  hideOnSubmitDelay: 1500,   // ms; only applies when hideOnSubmit is true
  showTitle: false,
  alignLeft: false,
  transparentBackground: false,
  trackEvents: true,
  hiddenFields: {            // pre-fill declared hidden fields
    ref: 'launch',
    utm_campaign: 'spring'
  },
  onSubmit: function (payload) {
    // payload = { formId, embedId, submissionId, page }
  }
});

2. closePopup#

Maxforms('closePopup', 'YOUR_FORM_CODE');
// or
Maxforms('closePopup', { formId: 'YOUR_FORM_CODE' });

3. on / off#

Subscribe to lifecycle events:

function handleSubmit(payload) {
  console.log('Form submitted:', payload.formId, payload.submissionId);
}

Maxforms('on', 'maxforms.form.submitted', handleSubmit);

// Later:
Maxforms('off', 'maxforms.form.submitted', handleSubmit);

See Events for the full event vocabulary.

4. init#

Reserved for future features (e.g. team-level keys). In v1 it's a no-op and you don't need to call it.

Maxforms('init', { teamKey: 'reserved-for-future-use' });

Keep reading

Was this helpful? Yes, it helped No, tell us why Still stuck? Contact support