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.
Name |
Parameters |
Description |
---|---|---|
sp.showPrivacyBanner(); |
None |
Forces the privacy banner to show. |
sp.hidePrivacyBanner(); |
None |
Forces the privacy banner to hide. |
sp.showTrustWidget(true); |
true |
Forces the trust widget to show. |
sp.hideTrustWidget(); |
None |
Forces the trust widget to hide |
sp.showCookieBanner(); |
None |
Forces the cookie banner to show |
sp.hideCookieBanner(); |
None |
Forces the cookie banner to hide |
sp.hidePrivacyPolicy(); |
None |
Forces the privacy policy popup to hide |
sp.showPrivacyPolicy(); |
None |
Forces the privacy policy popup to show |
sp.switchLanguage('lang_code'); |
None |
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); |
NA |
This method is used to add a listener to the window, that will get fired when secure privacy is all initialized. |
window.addEventListener( "sp_trust_badge_shown", function (evt) { console.log( evt); }); |
NA |
This method is used to add a listener to the window, that will get fired when trust badge is shown or hidden |
window.addEventListener( "sp_cookie_banner_shown", function (evt) { console.log(evt); }); |
NA |
This method is used to add a listener to the window, that will get fired when cookie banner is shown or hidden. the data which listener will get is |
window.addEventListener( "sp_cookie_banner_click", function (evt) { console.log(evt); });
|
NA |
This method is used to add a listener to the window, that will get fired when cookie banner's buttons is clicked. the data which listener will get is |
window.addEventListener( "sp_cookie_banner_save", function (evt) { console.log(evt); }); |
NA |
This method is used to add a listener to the window, that will get fired when cookie banner's buttons is clicked and it is saved. the data which listener will get is |
window.addEventListener( "sp_privacy_banner_shown", function (evt) { console.log(evt); });
|
NA |
This method is used to add a listener to the window, that will get fired when privacy banner is shown or hidden. the data which listener will get is detail: { true/false } here "detail: true" will be for privacy banner is shown and "detail: false" will be for privacy banner is hidden. |
window.addEventListener( "sp_privacy_banner_click", function (evt) { console.log(evt); });
|
NA |
This method is used to add a listener to the window, that will get fired when privacy banner's buttons is clicked. the data which listener will get is |
window.addEventListener( "sp_privacy_banner_save", function (evt) { console.log(evt); });
|
NA |
This method is used to add a listener to the window, that will get fired when privacy banner's buttons is clicked and it is saved. the data which listener will get is |
window.addEventListener( "sp_switch_lang", function (evt) { console.log(evt); }); |
NA |
This method is used to add a listener to the window, that will get fired when user changed language in privacy banner |
sp.cookieBannerVisible(); |
NA |
This function will return true when the cookie banner is visible on the screen, otherwise, it will return false. |
sp.savePluginConsent(pluginName); |
pluginName |
This method can be used to save consent for any particular plugin. The pluginName parameter expects a plugin name of type string. |
Comments
0 comments
Article is closed for comments.