General
You can use the Clinch SDK to manage and customize HTML creative widgets.
Important: These methods only apply to widgets used in HTML, in-banner video, and interactive video ads.
ClinchSDK Methods for Creative Widgets
The following methods are available for HTML creative widgets:
- clinchSdk.getAdStatus() - Returns the ad's status.
- clinchSdk.pause() - Pauses the ad.
- clinchSdk.play() - Resumes the ad.
- clinchSdk.goTo() - Positions the ad at a certain time point (in milliseconds).
- clinchSdk.mute() - Mutes the ad.
- clinchSdk.unmute() - Unmutes the ad.
- clinchSdk.setVolume() - Sets the ad audio's volume.
- clinchSdk.addEventListener() - Subscribes to events that the ad fires.
- clinchSdk.removeEventListener() - Unsubscribes from events that the ad fires.
- clinchSdk.click() - Initiates a click event.
- clinchSdk.engage() - Initiates an engagement event.
- clinchSdk.getAdContainer() - Returns the ad's container, used for measuring width and height and adding additional HTML elements (This container scales up/down according to the external container to maintain the ad's aspect ratio).
- clinchSdk.getExtAdContainer() - Returns the ad's external container, used for measuring width and height and adding additional HTML elements.
- clinchSdk.getDynImgUrl() - Wraps an image URL to serve it through the Clinch CDN and resizes the image if needed.
- clinchSdk.resizeFontToFitWidth() - Resizes a font for a text element to fit the element's width.
- clinchSdk.resizeFontToFitWidthForMultiLine() - Resizes a font and wraps the text as needed.
- clinchSdk.isMobile() - Returns a Boolean value indicating whether the widget/ad is on a mobile device.
- clinchSdk.getProductItems() - Returns an array of product items.
- clinchSdk.loadScript(url) - Loads the JavaScript file that is used as the widget's Script parameter value.
- clinchSdk.loadStyle(url) - Loads the CSS stylesheet file that is used as the widget's Style Sheet parameter value.
- clinchSdk.getConfigAndParent() - Returns the config object and parent element. (This method should be used by external scripts loaded via loadScript() when access to the config and parent is required.)
API Methods
clinchSdk.getAdStatus()
| Inputs | N/A |
| Output |
|
| Example Response | |
clinchSdk.pause()
| Inputs | N/A |
| Output | N/A |
| Notes | This is useful when a user performs an engagement that requires the ad animation to be paused, such as opening a "legal drawer." |
clinchSdk.play()
| Inputs | N/A |
| Output | N/A |
clinchSdk.goTo()
| Inputs | Composition time in milliseconds. |
| Output | N/A |
| Notes | This method, when used with the play() method, allows for ad replay functionality after an ad has ended. You can also use it to continue playing an ongoing ad from a certain time point without needing to use play(). |
clinchSdk.mute()
| Inputs | N/A |
| Output | N/A |
clinchSdk.unmute()
| Inputs | N/A |
| Output | N/A |
clinchSdk.setVolume(volume)
| Inputs |
|
| Output | N/A |
clinchSdk.addEventListener(eventType, cb)
| Inputs |
|
| Output | N/A |
| Notes |
|
clinchSdk.removeEventListener(eventType, CB)
| Inputs |
|
| Output | N/A |
clinchSdk.click(params)
| Inputs |
|
| Output | N/A |
| Notes |
|
clinchSdk.engage(params)
| Inputs |
|
| Output | N/A |
| Notes |
|
clinchSdk.getAdContainer()
| Inputs | N/A |
| Output | The ad container's size (example: 300x250). |
| Notes |
|
clinchSdk.getExtAdContainer()
| Inputs | N/A |
| Output | The external ad container's size (example: 300x250). |
| Notes |
|
clinchSdk.getDynImgURL(url, w, h, resizeOption, barsColor)
| Inputs |
|
| Output | The Clinch CDN URL of the resized image. |
| Notes |
|
clinchSdk.resizeFontToFitWidth(className)
| Inputs | className: The "class name" of the HTML element to which you want to apply this rule. |
| Output | N/A |
clinchSdk.resizeFontToFitWidthForMultiLine(className)
| Inputs | className: The "class name" of the HTML element to which you want to apply this rule. |
| Output | N/A |
| Notes |
|
clinchSdk.isMobile()
| Inputs | N/A |
| Output | Boolean value (True or False) |
clinchSdk.getProductItems()
| Inputs | N/A |
| Outputs | An array of product items |
clinchSdk.loadScript(url)
| Inputs | url (string): A script URL (the URL used as the widget's Script parameter value). |
| Outputs | A promise that is resolved when the file is loaded. |
clinchSdk.loadStyle(url)
| Inputs | url (string): A stylesheet URL (the URL used as the widget's Style Sheet parameter value). |
| Outputs | A promise that is resolved when the file is loaded. |
clinchSdk.getConfigAndParent()
| Inputs | N/A |
| Output |
params (object): Contains the widget's configuration data from the manifest (config) and the parent element, which is useful for external scripts that the widget loads:
|
| Notes |
|