API Extension (called EBAPI) is a module that provides additional functionality to the EB object.
To load the EBAPI module, add it to the EBModulesToLoad array in the index.html
file.
EBModulesToLoad = ['EBAPI'];
The EBModulesToLoad
code should be added to the section of your HTML before any reference to EBLoader or AdKit. For more information, see Load and Initialize the API.
Gets a variety of properties of a specific ad. Since ad properties are changed over time, rerunning this function will return most updated properties. It mostly retrives information from the adConfig, but also from other areas within the EB istelf.
var didUserAlreadyClickthrough = EB.getAdData(["isClickOccur"]).isClickOccur; console.log("ad has been clicked:", didUserAlreadyClickthrough);
var servingData = EB.getAdData(["adId", "placementId", "campaignId"]); console.log("ad ID is:", servingData.adId, ", campaign ID is:", servingData.campaignId);
Sets a variety of properties for the ad. Similar to EB.getAdData
but for writing instead of reading.
Name |
Type |
Parameter Type |
Description |
properties |
Object |
Path |
Name and value that defines the property. |
Type |
Description |
Object |
Empty if all requested properties had their value updated as required. Any that failed will be listed inside as |
Name |
Type |
Description |
elem |
HTMLElement |
Element to clip. |
top |
Number |
Distance from top edge to clip. |
right |
Number |
Distance from right edge to clip. |
bottom |
Number |
Distance from bottom edge to clip. |
left |
Number |
Distance from left edge to clip. |
Removes CSS "clip" style from an element by applying the value rect(auto auto auto auto)
to it.
Name |
Type |
Description |
top |
Number |
Distance from top edge to clip. |
right |
Number |
Distance from right edge to clip. |
bottom |
Number |
Distance from bottom edge to clip. |
left |
Number |
Distance from left edge to clip. |
Indicates whether an element, or list of elements, has a specific class attribute, or list of such classes.
Name |
Type |
Description |
elems |
HTMLElement | string | array |
Elements from which to remove the class. You can supply the HTMLElement, its ID, or an array of HTMLElement and/or IDs. |
classNames |
String | Array |
Classes to search for from the elements. You can supply a single string or an array of strings. |
requireAll |
Boolean |
(Optional) Determines whether to check if ALL the submitted elements to have the submitted classes, or if ANY of them have submitted classes. Default is true. |
Name |
Type |
Description |
elems |
HTMLElement | string | array |
Elements to which the class is applied. You can supply the HTMLElement, its ID, or an array of HTMLElements and/or IDs. |
classNames |
String | Array |
Classes to apply to the elements. You can supply a single string or an array of strings. |
shouldReplace |
Boolean |
(Optional) Determines whether to replace the existing class on the element or add to it. Default value is false; the supplied class will be added to any existing classes. |
Removes a class attribute from an HTML element.
Note
Note: Extra whitespace in the elements' className will be removed.
Name |
Type |
Description |
elems |
HTMLElement | string | array |
Elements from which to remove the class. You can supply the HTMLElement, its ID, or an array of HTMLElement and/or IDs. |
classNames |
String | Array |
Classes to remove from the elements. You can supply a single string or an array of strings. |
Retrieve the current value of a custom variable from the ad. Custom variables can be defined in the ad at runtime or in Sizmek Ad Suite (SAS) beforehand. For a list of name of the custom variables, see the Custom Variable Definitions in the build guides.
Name |
Type |
Parameter Type |
Description |
varName |
String |
Path |
Name of the custom variable that you want to retieve. |
def |
String | Number | Array | Object |
(Optional) Default value to be returned if the custom variable is not defined. |
Assuming your ad has a custom variable named mdPanelWidth
with a value of 600:
var myWidth1 = EB.getCustomVar("mdPanelWidth"); // "600" var myWidth2 = EB.getCustomVar("mdPanelWidth", "100"); // "600" - Default value has no effect because the value was already defined.
Assuming your ad has a custom variable named mdAutoSnapType
that has no predefined value:
var mySnap1 = EB.getCustomVar("mdAutoSnapType", 2); // 2 var mySnap2 = EB.getCustomVar("mdAutoSnapType"); // undefined
Sets a custom variable. It can either override the current value or only set it when it does not exist (actually setting a default value).
Name |
Type |
Parameter Type |
Description |
varName |
String |
Path |
Name of the custom variable that you want to set. |
value |
String | Number | Array | Object |
Value to write to the custom variable. |
|
override |
boolean |
(Optional) Determines whether existing values should be overwritten. Default is false. |
Assuming your ad has a custom variable named mdCloseButtonShow
with a value of true:
EB.setCustomVar("mdCloseButtonShow", false); // Does nothing because default value was already set to true. var show = EB.getCustomVar("mdCloseButtonShow"); // true EB.setCustomVar("mdCloseButtonShow", false, true); // Use the override. var show = EB.getCustomVar("mdCloseButtonShow"); // false
Returns an object with detailed information about the size and position of an element.
Note
Note: Typically, the viewport-relative and page-relative numbers will be the same inside the creative iFrame. The function is intended to mimic a similar function available to custom scripts running on the outside of the creative, so uses the same syntax.)
Name |
Type |
Description |
HTML element |
HTMLElement or String |
HTML Element reference or the ID of an element as a string. |
Type |
Description |
Object |
Object with the following properties:
|
Returns the highest number usable as a z-index by all browsers (except Firefox 2 and Safari 3). Some browsers can go higher, but this is the highest number that all browsers can use.
Injects an element to the DOM, according to the specified JSON object that represents the element attributes/children. The injection is done according to the specified method (injectionMethod) and using the specified element (refElem) as reference.
Name |
Type |
Description |
obj |
Object |
Object that represents the hierarchy of HTML elements for which we build the tags. Structure: {tagName:string, [attributes:{name1:value1, ... , style:{name2:value2}}], [children:{}]} |
injectionMethod(from EBG.Adaptors.InjectionMethod) |
String |
Describes where, in relation to the refElem, the new element should be injected. Acceptable values include:
|
refElem |
HTMLElement |
DOM element relative to which the injection is done. |
var tag = { tagName: "div", attributes: { dir: "ltr", id: "newDivTag", style: { display: "inline", position: "absolute", width: "100%" } }, children: [{ tagName: "iframe", attributes: { allowfullscreen: true, height: 1, id: "newIframeTag", style: { width: "1px", height: "1px" } } }] }; //add tag to the page and append it to a div with an id "adContainer" var el = document.getElementById("adContainer"); EB.inject(tag, EBG.Adaptors.InjectionMethod.APPEND, el);
Retrieves top left coordinate (positioning) for the resource. Position is relative to the creative iFrame window.
Retrieves top left coordinate (positioning) for the resource. Position is relative to the creative iFrame window.
Name |
Type |
Description |
elementId |
String |
ID attribute of the element for which to retrieve positioning. |
Determines the orientation of the creative iFrame window (not the parent page window) - either portrait (tall) or landscape (wide) aspect ratio.
Name |
Type |
Description |
elem |
HTMLElement |
Element from which to read the style. |
style |
String |
Name of the style property to return. |
inline |
Boolean |
Determines whether to return the inline style of the element, the computed style of the class, or the inherited/cascaded style from the element. |
Sets the style property of the specified element with given style property object. If the element does not accept a specified style property, the method will try to find a matching browser-prefixed equivalent to set instead. For the prefix-matching to work, use camelCase or InitialCaps property names, not kebab-case.
Name |
Type |
Description |
elem |
HTMLElement |
Element to which the style is set. |
style |
Object |
Object that describes the style to apply to the element, for example |
usePrefix |
Boolean |
(Optional) Default value is true. Determines whether to try to use a vendor-prefixed property in case the browser does not support the requested property. |
Similar to EB.setStyle, but allows you to pass an array of elements to set the same style to.
Name |
Type |
Description |
elem |
HTMLElement or Array of HTMLElements |
Element to which the style is set. |
style |
Object |
Object that describes the style to apply to the element, for example |
Gets the width and height of the creative iFrame. Note that inside the iFrame, viewport size, page size, and window size are all the same.
This method tells whether a specific custom interaction has been configured to close ad parts (collapse all panels).
MDX2.0

Sizmek Ad Suite (SAS)

Name |
Type |
Description |
interactionName |
String |
Name of the custom interaction for which to return a value. If blank, the value for clickthrough (_eyeblaster) will be returned. Case sensitive. |
Comments