Configuration options

The full shape of the window.insurely configuration object:

window.insurely = {
  config: {
    customerId: string,           // Your unique customer ID from Insurely (required)
    configName: string,           // The name of your specific configuration (required)
    language?: 'en' | 'sv' | 'da' | 'fr' | 'et',  // Interface language

    dataAggregation?: {
      referenceId?: string,       // Unique reference for this collection (max 50 chars, [a-zA-Z0-9@_-])
      advisorHandle?: string,     // Links collection to a specific advisor in your dashboard
    },
  },

  prefill?: {
    customer?: {
      email?: string,             // Customer's email address
      phoneNumber?: string,       // Customer's phone number
    },

    user?: {
      swedishPersonalNumber?: string,   // Format: YYYYMMDDXXXX
      estonianPersonalNumber?: string,
      estonianPhoneNumber?: string,
      norwegianPersonalNumber?: string,
      norwegianPhoneNumber?: string,
      username?: string,          // Login username or email (format depends on insurance company)
    },

    dataAggregation?: {
      company?: string,           // Pre-select a single company, e.g. "se-xxxx", "no-xxxx"
      companies?: string[],       // Pre-select multiple companies, e.g. ["se-xxxx", "no-xxxx"]
    },
  },
}

Available company codes can be found in the module's status information. Pre-selecting a single company skips the company selection step entirely.

Track what happens in the interface (optional)

The Insurely interface sends postMessage events during the data collection process. Listen for them to show progress indicators, track completions, or handle user actions like closing the interface.

Event nameValueDescription
WAITING_FOR_INITIALIZATIONThe module is waiting for initialization from bootstrap script
APP_LOADEDWhen the module and all its content is loaded
APP_CENTERScroll user to correct position when changing view (handled in bootstrap script)
PAGE_VIEWName of current pageSent on each page navigation. This is subject to change and we do not recommend to rely on this for tracking/analytic purposes
APP_CLOSEWhen user clicks on 'close'-icon on the results page. It sends the user back to start. But could be used to close the module if used in a webview context in an mobile app
SELECTED_AUTHENTICATION_METHODAuthentication methodWhen the user has selected an authentication method
COLLECTION_IDWill be sent right after the collection has started
RESULTSArray of collected dataThe format of the data is dependent on the backendAPI version that is used.
RESULTS_SELECTED_ITEMId of the selected insurance itemOnly for insurance.
COLLECTION_STATUSAll statuses in the data collection. The format of the data is dependent on the backendAPI version that is used.
OPEN_SWEDISH_BANKIDObject containing url and autostartTokenRequest to open the swedish BankID app

Listening for events:

window.addEventListener('message', ({ data }) => {
  console.groupCollapsed(`${data.origin}: ${data.name}`);
  console.log('Origin: ', data.origin);
  console.log('Name: ', data.name);
  console.log('Value: ', data.value);
  console.groupEnd();
});

Important note: The data format for the RESULT and COLLECTION_STATUS events is dependent on the backendAPI version that is used. This means that upgrading to a newer version of the backendAPI can change the format of the data.

Understand collection statuses

When a customer starts collecting their insurance data, the process goes through different stages. Here are the possible statuses you might see:

StatusDescription
RUNNINGThe collection process has started and is actively running
LOGINProcess is waiting for the user to provide login credentials
TWO_FACTOR_PENDINGProcess is waiting for the user to complete two-factor authentication
COLLECTINGActively gathering insurance data from the provider
COMPLETED_PARTIALCollection finished but only retrieved partial data (some data might be missing)
COMPLETEDCollection successfully finished with all expected data retrieved
COMPLETED_EMPTYCollection finished successfully but no insurance data was found
USER_INPUTProcess is waiting for additional input from the user
FAILEDCollection process encountered an error and could not complete
WAITING_FOR_AUTHENTICATIONProcess failed due to two-factor authentication timeout
CUSTOMER_ENROLLMENT_REQUIREDUser needs to enroll or register with the insurance provider before collection can proceed
INCORRECT_CREDENTIALSThe provided login credentials were invalid or incorrect

Receive the collected data (optional)

If you have a data processing agreement (DPA) with Insurely, you can receive the actual insurance data that was collected. This allows you to:

  • Store the data in your own system
  • Process it for your own analysis
  • Use it in your applications

Note: This feature requires a special agreement with Insurely and is only available to approved partners.

window.addEventListener('message', ({ event }) => {
  const { data } = event;

  if (data.name === 'RESULTS') {
    console.log('Collection data:', data.value);
    // Handle the collected data
  }
});

Last updated on