Advertisement deprecated

AppSuite features a basic framework to help implementing ads. Usually code snippets generated by some advertisment provider is meant to be used on static web sites. Integrating it into a web application might not be straight forward. That's why this framework has been created. It defines some common areas (ad spaces) to serve banners in different forms, it provides an API to refresh those banners on different events (e.g. app change, some timeout, …), and it helps to integrate the code snippets needed to actually run the campaigns by the provider.


Configuration for the io.ox/ads framework must be provided by a plugin in the namespace io.ox/ads.

All registered plugins for io.ox/ads will get loaded and the return values of their modules will be handed as parameters for invocation of the inject method (with this being bound to $('head')) as well as the config method of the extension point io.ox/ads. It is therefore possible to customize this functionality by extending io.ox/ads.

When using the default implementation, custom modules should return an object containing two keys:

  • inject - a String with valid HTML code which is to be appended to the head element
  • config - the configuration is simply stored internally

The config object can contain arbitrary data. The changeModule method of the io.ox/ads extension point will be invoked with the app name as first parameter and a Baton containing a reference to the app and the config object.

The default implementation expects the config object to contain one key for each space. Values for these keys used in the default implementation should be an object defining:

  • space - a String which defines the desired target space for this ad
  • html - a String which is appended to the corresponding space
  • reloadAfter - a number value, representing the time until the next refresh operation for an area is invoked
  • showInModules - falsy value (always active) OR an array with app names to match against (e.g. 'io.ox/mail', …)

For every defined area, the cleanup method of the corresponding extension point will be invoked. Active spaces are determined by filtering using showInModules options in the area configuration. By extending io.ox/ads extension point implementing the filter method, the filtering behaviour can be customized. For every active area, the draw method of the extension point will be invoked. (See Spaces section) The reload method of the area extension point will be invoked in a regular interval defined by the value of reloadAfter. The configuration object will be passed to each method invocation.


Easy access to the gathered configuration is possible via the io.ox/ads/config module. The provided methods are:

  • load: store a given configuration. No need to call this manually, the framework uses this internally. In case you need to add configuration later, this function can be used.
  • get: get all configuration values in an Array
  • forSpace: only return configuration for a given space name


There is a list of extension points defined, which can be used to place banners. All points share a similar API:

    cleanup: function (baton) { /* do some cleanup */ },
    draw: function (baton) { /* append to the spaces element, do other stuff */ },
    reload: function (baton) { /* trigger a reload of the banner */ }
    defaults: function (baton) { /* add default values to, like for sizes or size mappings */ }

The following ad spaces are pre-defined and can be used to serve ads:

  • io.ox/ads/leaderboard
  • io.ox/ads/skyscraper
  • io.ox/ads/skyscraperLeft
  • io.ox/ads/driveFolder
  • io.ox/ads/portalBackground
  • io.ox/ads/portalBillboard
  • io.ox/ads/mailBackground
  • io.ox/ads/mailDetail
  • io.ox/ads/mailSentOverlay
  • io.ox/ads/logout

In order to activate one of these spaces, a custom plugin is needed, shipping a configuration as described above.

Default values

The implementation of the ad space extension points provide a defaults method that can be invoked to get some default configuration values. The results will be stored in the data section of a Baton object. The current implemntation allows to fetch default sizes and size mappings (mappings of screen space to banner sizes, see GPT documentaiton for details) for all ad spaces. Those can of course be customized by implementing a custom defaults method for each ad space extension. These sizes contain tested values, which are known to work quite well in AppSuite context.

Usage example:

var defaults = ext.Baton.ensure({
    sizes: [],
    sizeMappings: []
ext.point('io.ox/ads/leaderboard').invoke('defaults', undefined, defaults);

Besides sizes and sizeMappings, many spaces define default values for the showInModules configuration attribute.

Utility API

Most ad campaigns share common needs regarding functionality. The io.ox/ads framework provides a set of tools to simplify custom implementations.


Sometimes, there are events that should trigger a reload of ad banners, but should not do so too frequently. You want an ad space to cool down a certain amount of time, before a reload is actually triggered. That's where Cooldown timers come in handy.

To use those timers, a new instance of the Cooldown util class is needed:

var config = loadConfig(); // the current list of configured ads
var Cooldown = require('io.ox/ads/util').Cooldown;
var cooldown = new Cooldown(config);

The instance can then be used like this:

    reload: function (baton) {
        cooldown.touch( () {
            // do the refresh, only called if space is "cool"
        }, function () {
            // ad space is too hot, did not refresh, but may be collect some metrics?

// reset cooldown timer for third banner in configuration
var id = 2;

// reset all cooldown timers

List of ad spaces

For convenience, there is a list of ad spaces provided through the utility class. It can be used to iterate over all spaces:

util.spaces.forEach(function (space) {
    ext.point(space).extend(/* … */);

Module mappings

For convenience, a mapping from generic “module names” to specific module ids is provided. This mapping can be used to refer to a group of modules which belong together, like a mapping from mail to ['io.ox/mail', 'io.ox/mail/detail', 'io.ox/mail/compose']. The main purpose is to use it in the configuration:

  "space": "io.ox/ads/leaderboard",
  "showInModules": ["mail", "portal"]


The default behavior can be completely customized using well-known methods, extension points. Despite the special points for the spaces as described above, it is possible to extend the general point io.ox/ads. The API for this point looks like this:

    changeModule: function (baton) { /* do something if user opens a new app/module */ },
    filter: function (baton) { /* result is expected in baton.activeAds, apply your filter function here */ },
    config: function (baton) { /* do something with the configuration */ },
    inject: function (baton) { /* inject the global JS from ad provider, this variable is bound to $('head') */ }

As a reference implementation and a starting point, this project can be used. The implementation is used to demonstrate the integration of a few spaces using a little more than just a minimal configuration.

Google Publisher Tag

The io.ox/ads API natively supports using Doubleclick GPT as a provider for ad space content. Implementing a campaign should be possible without any JavaScript code, by just providing configuration for the desired slots. This is achieved using the default values feature.

A minimal configuration for the io.ox/ads/leaderboard ad space might look like this:

    "space": "io.ox/ads/leaderboard",
    "gpt": {
        "adUnitPath": "/1234567/test_ads"
    "cooldown": 5000,
    "reloadAfter": 30000

This will setup an automatic reload after 30s and installing a cooldown timer to not refresh before 5s have past since the last reload event. Banners will be served from the ad unit /1234567/test_ads, which needs to be defined within GPT.

Incompatible changes since 7.8.2 release

Removed some filters from the default implementation

Filters that can easily be implemented in the middleware, have been removed from frontend code. Those attributes are not used to filter the list of active ads any longer:

  • capabilities
  • active

In order to add custom support this, use the io.ox/ads extension point and implement a custom filter method.

    filter: function (baton) {
        baton.activeAds = baton.activeAds.filter(function(conf) {
            return && capabilities.has(conf.capabilities);