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 name | Value | Description |
|---|---|---|
| WAITING_FOR_INITIALIZATION | The module is waiting for initialization from bootstrap script | |
| APP_LOADED | When the module and all its content is loaded | |
| APP_CENTER | Scroll user to correct position when changing view (handled in bootstrap script) | |
| PAGE_VIEW | Name of current page | Sent on each page navigation. This is subject to change and we do not recommend to rely on this for tracking/analytic purposes |
| APP_CLOSE | When 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_METHOD | Authentication method | When the user has selected an authentication method |
| COLLECTION_ID | Will be sent right after the collection has started | |
| RESULTS | Array of collected data | The format of the data is dependent on the backendAPI version that is used. |
| RESULTS_SELECTED_ITEM | Id of the selected insurance item | Only for insurance. |
| COLLECTION_STATUS | All statuses in the data collection. The format of the data is dependent on the backendAPI version that is used. | |
| OPEN_SWEDISH_BANKID | Object containing url and autostartToken | Request 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:
| Status | Description |
|---|---|
| RUNNING | The collection process has started and is actively running |
| LOGIN | Process is waiting for the user to provide login credentials |
| TWO_FACTOR_PENDING | Process is waiting for the user to complete two-factor authentication |
| COLLECTING | Actively gathering insurance data from the provider |
| COMPLETED_PARTIAL | Collection finished but only retrieved partial data (some data might be missing) |
| COMPLETED | Collection successfully finished with all expected data retrieved |
| COMPLETED_EMPTY | Collection finished successfully but no insurance data was found |
| USER_INPUT | Process is waiting for additional input from the user |
| FAILED | Collection process encountered an error and could not complete |
| WAITING_FOR_AUTHENTICATION | Process failed due to two-factor authentication timeout |
| CUSTOMER_ENROLLMENT_REQUIRED | User needs to enroll or register with the insurance provider before collection can proceed |
| INCORRECT_CREDENTIALS | The 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