support home

Back to website
Welcome
Login  Sign up

re-open cookie-consent modal via js

Hello,

as a frontend-developer, I want to re-open the cookie-policy with a link via javascript.

Currently I have create a link like <a href="#" class="iubenda-cs-preferences-link" >Cookies</a>. But this way, I suffer under the behavior, that only the first of such links does work. On our page, we use different footers (on different pages), where this link is included; and only the first does work; the 2nd one only works after a reload.

The class usage is like documented in the documentation (german version). 

I would like to have a JS-API-function like #showCP() or that a your class-name based solutions also works on links, loaded afterwards.

Feel welcome to forward this message or provide a different solution.


3 people like this idea
  • sorry for bouncing this topic; this is a serious request and we need a solution for it from you.

  • Oh, same problem i m facing.

  • I've installed the Iubenda Consent Solution JS SDK, and it appears to work. Once a user indicates their consent by scrolling or dismissing the notice, the banner goes away and, presumably, the consent is stored in the Iubenda system.        

    Once the consent is recorded, one must be able to retrieve it and Iubenda says this can be done using either the HTTP API or by JavaScript, however these methods are not well documented.

    How can I use JavaScript to retrieve the consent?

     

  • I'm not part of the Iubenda team but I have similar problems and these are the solutions I found so far


    To open the generic dialog (requires the link in the page)

    document.querySelector('.iubenda-cs-preferences-link').click();

     


    To open only the TCF panel

    _iub.cs.openAdvertisingPreferences()

     


    To retrieve the GDPR consent
    use the iubenda callbacks in the configuration

    callback: {
        onPreferenceExpressedOrNotNeeded: function(preferences) {
            console.log(preference);
        }
    }

     

    To retrieve the TCF consents use the __tcfApi 

    __tcfapi('getTCData', 2, function(tcdata, success) {
        console.log(tcdata);
    }

      

    Waiting for the support team to confirm, and more solid and documented methods to do this

Login or Signup to post a comment