Skip to content

Runtime API

ACE Widgets offer extensive customization options within the ACE Portal. However, certain integrations may require custom JavaScript implementations. The Runtime API provides methods to fine-tune widget behaviors on your website, such as controlling when a widget is activated and managing cookie policies.

The Runtime API becomes accessible via the window.ace object immediately after the ACE Widgets embed code is executed in the DOM.

Interacting with Specific Widgets

To interact with a specific widget, use the ace.widget() function. This function returns a widget object associated with the specified widget name, enabling you to control the widget programmatically, including opening and closing it.

Opening a Widget

To open a widget programmatically, use the following code:

ts
ace.widget('my-widget', (widget) => {
  widget.open();
});

Closing a Widget

To close a widget programmatically, use the following code:

ts
ace.widget('my-widget', (widget) => {
  widget.close();
});

Setting a Widget's Z-index

To set z-index programmatically, use the following code:

ts
ace.widget('my-widget', (widget) => {
  widget.setZIndex(10);
});

The setZIndex() function takes an integer value as the new z-index for the widget. This example sets z-index to 10.

Site-Wide Configuration

For configurations that apply across the entire site, the ace.configure() function is available. This function allows you to set global policies and behaviors.

Managing Storage Policies

To manage cookie storage policies for your site, use the storagePolicy() method. This is particularly useful for enforcing compliance with privacy regulations. For detailed information, refer to the Cookies Documentation.

ts
ace.configure((site) => {
  site.storagePolicy(['necessary']);
});

This example configures the site to only allow cookies that are classified as "necessary."