Radical API
Radical API is a set of methods and properties that you can use to manage your creatives. You can use the API to access and control the elements in your creatives.
RAD object
Our rendering library called Radical exposes some helper functions you can you while working on your creative you can access them by initializing the `rad` object by calling
The majority of functions available on the object are used internally by Radical, but a couple of them will come in handy when working with the creative.
This is called after all the elements in the creation are rendered and positioned by the Radical. Use the onLoad event to add DOM event listeners (click, mouse enter, mouse leave, ...) because onRender is called multiple times when you resize the ad, and the listeners would be added multiple times.
This is called after the flowline for the creative was loaded but before the render. This is a good place to add any DOM event listeners, as this is called only once.
This event returns elements object with all the properties it they will render. You have an option to change these properties before the rendere here. Just update the object. The object is composed of keys that are element ID-s and values that are corresponding properties.
An array of all layout sizes we can render from. In the case of Fully-fluid format, this array is empty.
Size object of the layout currently rendering.
You can use `getElementById` to get an element reference, make sure you are calling this inside `onRender` callback. Check boilerplate code, for example. getElementById returns an object with `domNode` property pointing to actual DOM element and some other information about the element. Some elements, like the video, also contain useful functions to control the element.
All Functions
You can follow the Custom JavaScript Guide to learn how to use the Radical API in your creatives.
Name
addGlobalEventListener(event: string, callback: (arg: any) => void)
DescriptionAdds a global event listener to the creative. The event listener will be triggered when the specified event occurs in the creative.
Name
animationTime(time: number)
DescriptionSets the animation time of the creative to the specified time in milliseconds.
Name
callTrackerURL(url: string)
DescriptionCall the specified tracker URL.
Name
clearElements(elements: HTMLElement[])
DescriptionClears the specified elements from the creative.
Name
condeHideAd()
DescriptionHides the creative.
Name
createLightboxContainer()
DescriptionCreates a lightbox container.
Name
creativeTimeSpent()
DescriptionReturns the time spent on the creative in milliseconds.
Name
domEventHandler(event: string, callback: (arg: any) => void)
DescriptionAdds a DOM event listener to the creative. The event listener will be triggered when the specified event occurs in the creative.
Name
forceRender()
DescriptionForces the creative to render.
Name
generateUUID()
DescriptionGenerates a UUID.
Name
getActiveConfig()
DescriptionReturns the active config of the creative.
Name
getAdContent()
DescriptionReturns the ad content of the creative.
Name
getAdRenderer()
DescriptionReturns the ad renderer of the creative.
Name
getAdTagOptions()
DescriptionReturns the ad tag options of the creative.
Name
getAdVersion()
DescriptionReturns the ad version of the creative.
Name
getAnimationTimeline()
DescriptionReturns the animation timeline of the creative.
Name
getAssets()
DescriptionReturns the assets of the creative.
Name
getConfig()
DescriptionReturns the config of the creative.
Name
getContainer()
DescriptionReturns the container of the creative.
Name
getCookie(name: string)
DescriptionReturns the value of the specified cookie.
Name
getCurrentMediaquery()
DescriptionReturns the current media query of the creative.
Name
getDataLayer()
DescriptionReturns the data layer of the creative.
Name
getDeviceInfo()
DescriptionReturns the device info of the creative.
Name
getElementById(id: string)
DescriptionReturns the element with the specified ID.
Name
getElementChildren(element: HTMLElement)
DescriptionReturns the children of the specified element.
Name
getElementStyles(element: HTMLElement)
DescriptionReturns the styles of the specified element.
Name
getExtension(extensionType: string)
DescriptionReturns the extension of the specified type.
Name
getFormatLayouts()
DescriptionReturns the format layouts of the creative.
Name
getLbNro()
DescriptionReturns the lightbox number of the creative.
Name
getMergedContent()
DescriptionReturns the merged content of the creative.
Name
getRenderedSize()
DescriptionReturns the rendered size of the creative.
Name
getSizeFilter()
DescriptionReturns the size filter of the creative.
Name
getState()
DescriptionReturns the state of the creative.
Name
getUUID()
DescriptionReturns the UUID of the creative.
Name
getUserInfo()
DescriptionReturns the user info of the creative.
Name
getVisibleElementChildren(element: HTMLElement)
DescriptionReturns the visible children of the specified element.
Name
hideCreative()
DescriptionHides the creative.
Name
isAdContentAvailable()
DescriptionReturns true if the ad content is available, otherwise false.
Name
isOpenStateAdObj()
DescriptionReturns true if the ad object is in open state, otherwise false.
Name
onAdContentAvailable(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the ad content is available.
Name
onAdHover(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the ad is hovered.
Name
onAnimationProgress(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the animation progresses.
Name
onBeforeRender(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered before the creative is rendered.
Name
onCarouselFirstSlide(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the carousel is on the first slide.
Name
onCarouselLastSlide(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the carousel is on the last slide.
Name
onCarouselMiddleSlide(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the carousel is on the middle slide.
Name
onClick(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the creative is clicked.
Name
onCountdownFinished(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the countdown finishes.
Name
onElementHover(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when an element is hovered.
Name
onElementMouseOut(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the mouse leaves an element.
Name
onLoad(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the creative is loaded.
Name
onMediaEnded(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the media ends.
Name
onMediaPause(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the media is paused.
Name
onMediaPlaying(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the media is playing.
Name
onPreviewVideoEnd(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the preview video ends.
Name
onPreviewVideoStart(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the preview video starts.
Name
onRender(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the creative is rendered.
Name
onVideoEnd(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video ends.
Name
onVideoMuted(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video is muted.
Name
onVideoPause(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video is paused.
Name
onVideoPlay(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video is played.
Name
onVideoTimeUpdate(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video time is updated.
Name
onVideoUnMuted(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video is unmuted.
Name
onVideoUnableToAutoplay(callback: (arg: any) => void)
DescriptionAdds a callback to be triggered when the video is unable to autoplay.
Name
pauseAnimation()
DescriptionPauses the animation of the creative.
Name
playAnimation()
DescriptionPlays the animation of the creative.
Name
previewPageForceRender()
DescriptionForces the creative to render the preview page.
Name
refreshInteractionDisable()
DescriptionDisables the refresh interaction of the creative.
Name
removeGlobalEventListener(event: string, callback: (arg: any) => void)
DescriptionRemoves the specified global event listener from the creative.
Name
renderElement(element: HTMLElement)
DescriptionRenders the specified element in the creative.
Name
renderElementWithStyles(element: HTMLElement, styles: any)
DescriptionRenders the specified element in the creative with the specified styles.
Name
restartAnimation()
DescriptionRestarts the animation of the creative.
Name
seekAnimation(time: number)
DescriptionSeeks the animation of the creative to the specified time in milliseconds.
Name
sendAdformAnalyticsEvent(event: string, data: any)
DescriptionSends an Adform analytics event with the specified event and data.
Name
sendAnalyticsEvent(event: string)
DescriptionSends an analytics event with the specified event.
Name
setConfig(config: any)
DescriptionSets the config of the creative to the specified config.
Name
setCookie(name: string, value: string, options: any)
DescriptionSets the specified cookie with the specified value and options.
Name
setCustomTracker(tracker: any)
DescriptionSets the custom tracker of the creative to the specified tracker.
Name
setLbNro(nro: number)
DescriptionSets the lightbox number of the creative to the specified number.
Name
setProgressAnimation(progress: number)
DescriptionSets the progress of the animation of the creative to the specified progress.
Name
setResponsiveMode(mode: string)
DescriptionSets the responsive mode of the creative to the specified mode.
Name
setSizeFilter(filter: any)
DescriptionSets the size filter of the creative to the specified filter.
Name
setState(state: any)
DescriptionSets the state of the creative to the specified state.
Name
setVideoInViewPercetage(percentage: number)
DescriptionSets the percentage of the video in view to the specified percentage.
Name
start()
DescriptionStarts the creative.
Name
startAnimation()
DescriptionStarts the animation of the creative.
Name
stopAnimation()
DescriptionStops the animation of the creative.
Name
updateAgTagOptions(options: any)
DescriptionUpdates the ad tag options of the creative to the specified options.
Name
updateAnimationTimeline(timeline: any, time: number)
DescriptionUpdates the animation timeline of the creative to the specified timeline and time.
Name
updateCustomCSS(css: string)
DescriptionUpdates the custom CSS of the creative to the specified CSS.
Name
updateCustomJs(js: string)
DescriptionUpdates the custom JavaScript of the creative to the specified JavaScript.
Name
updateElementStyles(element: HTMLElement, styles: any)
DescriptionUpdates the styles of the specified element to the specified styles.
Last updated
Was this helpful?