Developer guide for JavaScript methods


By Manish Gautam

updated 16 days ago

The Secure privacy script loads a client-side JavaScript object named 'sp' which exposes the following public methods. Use these methods optionally to trigger your banners.


sp.showPrivacyBanner();NoneForces the privacy banner to show.
sp.hidePrivacyBanner();NoneForces the privacy banner to hide.
sp.showTrustWidget(true);trueForces the trust widget to show.  
sp.hideTrustWidget();NoneForces the trust widget to hide
sp.showCookieBanner();NoneForces the cookie banner to show
sp.hideCookieBanner();NoneForces the cookie banner to hide
sp.hidePrivacyPolicy();NoneForces the privacy policy popup to hide
sp.showPrivacyPolicy();NoneForces the privacy policy popup to show

This method changes the language of all the banners. You need to pass 2 character language code, for example, 'en' or 'sv'. lang_code must be any language code that is activated for that domain.

sp.switchLanguage('lang_code', 'cookieBanner');None

This method changes the language of the cookie banner. It overrides all the default settings and forces the cookie banner to show.

window.addEventListener("sp_init", function (evt) {console.log(evt.detail);}, false);
NAThis method is used to add a listener to the window, that will get fired when secure privacy is all initialized.

Did this answer your question?