Configuration

The Green Housing widget accepts custom configuration parameters that can be provided via an optional configuration object. If possible, we highly encourage to use the Ecmascript module bundle of Green Housing which offer a seamless TypeScript integration, making configuration easy and safe to implement and maintain.

const myCustomConfig = {
  translations: {
    [ "SV_SE"]: {
      "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.

{
  // Parameters affecting the result calculations, e.g interest rates and CO2 conversion rates. Read more below at "Calculation parameters".
  // Merge: ✅
  calculationsParameters: {}

  // 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),

  // Selected language for the widget. Can be set to "SYSTEM_DEFAULT" to first hand use browser language, or a language code to use a specific language.
  // Merge: ❌ 
  selectedLanguage: "SYSTEM_DEFAULT",

  // Custom translations, more information below at "Translations".
  // Merge: ✅
  translations: {
    "en-GB": {
      "namespace:translation.key": "custom translation"
    }
  }

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

List of available parameters for the configuration object

Calculation parameters

Please refer to Calculation parameters for a full list of available parameters.

onEvent

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

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

Translations

Translations can be specified for multiple languages using language codes as keys.

const myCustomConfig = {
  translations: {
    "SV_SE": {
      "namespace:some.translation.key": "Någon anpassad översättning",
      "namespace:another.key": "En annan översättning"
    },
    "EN_GB": {
      "namespace:some.translation.key": "Some custom translation",
      "namespace:another.key": "Another translation"
    },
    "DE_DE": {
      "namespace:some.translation.key": "Eine benutzerdefinierte Übersetzung",
      "namespace:another.key": "Eine andere Übersetzung"
    }
  }
};

Example of configuring translations for multiple languages

See Languages & translations for more information about available translation keys and how to implement custom translations.

The Green Housing widget require 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. 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.