DG and Privacy UX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Consent Solutions Knowledge Base

UCP Javascript API Part 3/3

Continued from part 2..

getBannerStyle()

Use this method if you need to pull the styles for the banner object.

getBarrierStyle()

Use this method if you need to pull the styles for the barrier object.

getButtonStyle()

Use this method if you need to pull the styles for the consent tool button object.

getLinkStyle()

Use this method if you need to pull the styles for the consent tool link object.

getL2Style()

Use this method to pull the styles used for the options dialog. This is called “L2” because that is how we refer to the options dialog internally.

getTranslations()

Returns the active set of translations.

formatTranslation(text)

text: the translation text to apply formatting to

This method will execute a string replace on the passed in string to replace some string markers with dynamic values. Currently this method will replace the following:

{company} – current company division name
{consentToolUrl} – the url to the cookie consent tool for the active notice/country combination. {privacyPolicy} – any privacy policy url assigned to the active notice/country combination.

dropSuppressionCookie(days)

days: an integer value indicating the number of days to set the cookie for. Leave this as null or 0 to drop a session cookie.
Use this method to drop a cookie to “suppress” the display of the consent UI elements (banner/barrier). This allows our customers to comply with the GDPR instructions of allowing a user to access site content without providing consent.

setUserIdentifier(id)

id: a string value which will be stored as the user identifier for the current user.

Use this method to assign a user identifier which can be stored with the reporting information for the active user. This should be some sort of internal identifier which will allow you to identify specific users for actions such as consent. It can also help improve the general reporting from the UCP by using a unique identifier instead of the correlation key we typically use for reporting, which is not guaranteed to represent a unique user.

NOTE: you can also set the user identifier using the window.evidon.userid property. Since the window.evidon.userid property can be set available before the notice api is available using that property instead of this api method can help prevent timing issues where the user id is not set before the reporting calls fire, causing the identifier to be excluded from the call. However,

both are supported and this call will override the id value if it is set on the window.evidon.userid property so be aware of that.

withdrawConsent()

Use this method to withdraw consent for the active user. When called this method will remove our consent cookie and then call the consentWithdrawnCallback event to execute any code located in that callback.

window.evidon.banner namespace

The following list of methods are supported under the window.evidon.banner namespace.

IEVersion()

Helper method called to return the current version of IE the scripts are running on. We have some conditional code blocks which execute differently on earlier version of IE then more modern browsers.

closeBanner(eventObj)

eventObj: a standard event object received from javascript click events.

This is the click handler from the banner accept button and close icon. You can call it from your own code if you want to simulate a click event but it is recommended you use the window.evidon.notice.consentGiven() api instead.

acceptButtonClicked(eventObj)

eventObj: a standard event object received from javascript click events.

This is the callback executed when someone clicks our Accept button. If you need to simulate an Accept button click use this method.

optionButtonClicked(eventObj)

eventObj: a standard event object received from javascript click events.

This is the callback executed when a user clicks our Options button on the banner. If you need to simulate an Option button click call this method.

closeIconClicked(eventObj)

eventObj: a standard event object received from javascript click events.

The callback executed when someone click the close icon on the banner. If you need to simulate the close icon click call this method.

endsWith(source,value)

source: source string to check
value: value to look at the end of the source string for

This is just a helper method which returns a Boolean true if the source string ends with the passed in value.

isOnBanner(element)

element: An element object

This method is a helper method that returns true if the given element object is actually located on our banner display. It is used to keep us from executing a consent event if someone clicks at some random place on the banner. It is unlikely you will need to use this method for anything.

closeConsentBanner()

Instructs the banner to close. This method does not execute any consent functionality. It should only be used if you want to hide the banner without a user consenting for some reason.

getBannerStyle()

Returns the style used to format the banner on the page. This is just a helper method which makes sure some specific values (z-index for example) are present in the styles being applied to the banner.

createAcceptButton()

Just a helper method which creates a formatted Accept button. There probably isn’t a good use case for a customer using this, but it’s there if you need it.

createOptionButton()

A helper method to create the option button displayed on the banner.

createCloseIcon()

A helper method to create the close icon displayed on the banner.

createBanner()

Method called when the script loads to create the banner structure.

setTextValues(translations)

translations: an object containing the string values for the various banner elements.

This is called to apply the given translations to the banner. Typically this is called from our main notice script if the language is changed. It is highly recommended you just use our user interface to make any translation changes, but if you need to force these to be different for some reason you can use this method.

createNotice()

Called to create the notice and show it on the page. This is called as soon as the script loads so it is unlikely you will need to use it, but if you have to force the banner to display this method will do that.

destroyNotice()

Instructs the notice to close and remove itself from the dom. Calling this method does not trigger any type of consent actions or drop the consent cookie. You can use this method if you need to remove the banner from the current page for some reason.

scaleForMobile()

This is a helper method called to apply a zoom on the banner if displayed on a mobile device. It is unlikely this method needs to be used by any customers.

window.evidon.barrier namespace

The follow list of methods are supported under the window.evidon.barrier namespace.

createBarrierNotice()

Runs the barrier creation routine.

destroyNotice()

Closes the notice and removes it from the DOM.

showCookieConsentTool()

Not well named. If the Options Dialog is enabled this will run the enabled functionality of the options dialog. If not this will show the iFramed consent tool in the barrier.

window.evidon.gdprL2 namespace

The following list of methods are supported under the window.evidon.gdprL2 namespace.

NOTE: this object is only available in the window.evidon object after the script has been loaded, which occurs the first time the overlay is triggered to display.

showOverlay()

Execute this method to show the GDPR overlay.

closeOverlay()

Execute this method to hide the GDPR overlay. This call closes the GDPR overlay and removes it from the DOM.

window.evidon.cmp namespace

This is the object that powers the UCP support of the IAB GDPR framework (cmp stands for Consent Management Provider). Currently we do not support using this API directly. Instead you need to use the window.__cmp object which is defined in the IAB EU specifications. (Specification located at: https://github.com/InteractiveAdvertisingBureau/GDPR- Transparency-and-Consent-Framework/blob/master/CMP%20JS%20API%20v1.1%20Final.md )

The evidon implemention of the __cmp support provides full support for that specification.

In the near future we will be extending this API to provide more control over various pieces of functionality. As that happens we will extend this documentation to include the supported methods provided for that purpose.

Labels (3)
Attachments
Version history
Revision #:
2 of 2
Last update:
‎05-15-2019 07:46 PM
Updated by:
 
Contributors
Looking for more?
Ask in Discussions
Developers

Peer-to-peer support  and answers on developing CMS templates, modifying privacy scripts or building integrations.

Digital Experience Management

Find answers and ask questions on content management, personalization and targeting.

Digital Quality Management

Find answers and ask questions on WCAG and SEO quality management.

Digital Governance

Find answers and ask questions on consent and monitoring solutions.