Configuration

The Green Housing widget accepts custom configuration parameters that can be provided via an optional configuration object.

const myCustomConfig = {
  translations: {
    "some:translation.key": "Some custom translation",
  },
};

EconansGreenHousing.mount("#widget", myCustomConfig);

Example of mounting the widget with a custom configuration

Configuration parameters

The following parameters represent the custom configuration options. Those marked as Merge (only applicable to arrays or objects) will merge with any existing pre-configuration and will only override if an identifier or value is the same (e.g., extending an array but overriding specific values). Any other properties will completely replace any existing pre-configuration.

{
  // Needed to activate various features. Values are by default `false`.
  // Merge: ✅
  userCookieConsent: {
    functional: boolean | function,
    tracking: boolean | function
  },

  // Object that contains content to display in leads. More information below at "Leads".
  // Merge: ✅
  leads: object,

  // Function that is called with event data when certain events occur. Use it to for example track user interactions in Google Analytics.
  // Merge: ❌
  onEvent: function(event),

  // Custom translations, more information below at "Translations".
  // Merge: ✅
  translations: {
    translationKey: "custom translation"
  }
}

List of available parameters for the configuration object

The Green Housing widget requires user cookie consent for certain features to be activated or to work fully and detailed settings can be provided for different scopes.

These parameters are optional, and their default values are false. You can provide either a boolean or a function that returns a boolean as a value. The latter is executed each time an event is triggered and is therefore a recommended approach if the cookie consent might change after the Green Housing widget has been mounted.

function getTrackingConsent () {
    if (userCookieSettings.tracking) {
        return true
    }
    return false
}

const configurationOverrides = {
    ...
    userCookieConsent: {
        functional: true,
        tracking: getTrackingConsent,
    }
    ...
}

Example of cookie consent configuration

functional

Functional cookies allow us to store information for features such as that a user can return to the product at a later date and continue their previous session.

tracking

If Econans has activated tracking for user analytics, this parameter will allow/prevent tracking of recurring users. Any provided onEvent function will not be affected.

Note: The tracking feature is only included by agreement, contact us at hello@econans.com for further info.

Leads

Leads are small “ads” that are displayed on the result page. They can be used to promote your own products or services, or to promote other products or services that you are affiliated with.

Leads are usually displayed in a list, but there is also a special type of lead called “highlighted” that is displayed separately.

const configurationOverrides = {
  ...
  leads: {
      highlighted: {...},
      regular: [{...}]
  },
  ...
}

Read more about leads here.

onEvent

The onEvent(event) function is called when specific events occur and can be utilized, for instance, to monitor user interactions using Google Analytics.

var configurationOverrides = {
    ...
    onEvent(event) {
        if (event.source === "user") {
            externalTrackingService.track(event)
        }
    },
    ...
}

See Tracking events for more information.

Translations

See Translations for more information.