• Resolved pramakrishna

    (@pramakrishna)


    Hi,
    I am trying to add this code
    <script type=”text/javascript”>

    window.addEventListener(‘CookiebotOnAccept’, function (e) {
    if (Cookiebot.consent.marketing)
    {
    //Execute code that sets marketing cookies
    }
    }, false);

    </script>
    inside my code to customize the plugin and I am getting error saying “Cookiebot” is not defined and not able to go further. Please suggest me how to add the code inside our javascript file

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter pramakrishna

    (@pramakrishna)

    Especially for this line “Cookiebot.consent.marketing”

    Its a little urgent task. So I would appreciate for a quick response

    Thanks in advance.

    Plugin Author cookiebot

    (@cookiebot)

    Hi @pramakrishna,

    Thanks for reaching out.

    This happens when the Cookiebot script (uc.js) is not added to the website that you are trying to use the code on.

    How are you adding Cookiebot to your site? Would it be possible to update your question with a link so that we can test. Otherwise, you can also send us a link at: [email protected] – Thanks!

    Thread Starter pramakrishna

    (@pramakrishna)

    Hi,

    Thanks for the quick reply. I am using the WordPress plugin so the script tag is automatically added to the head section like this

    <script id=”Cookiebot” src=”https://consent.cookiebot.com/uc.js&#8221; data-cbid=”” type=”text/javascript” async=””></script>

    And also, to give you the link, its a little difficult because I’m currently testing on my internal staging WordPress link.

    This link is absolutely fine
    “window.addEventListener(‘CookiebotOnAccept’, function (e) {”

    Its giving error only for this line “if (Cookiebot.consent.marketing)”

    Thread Starter pramakrishna

    (@pramakrishna)

    I am trying to create a function where we can withdraw from one particular cookie for eg marketing/statistics only when we are using a banner with “Allow all cookies” button without any checkboxes.

    So is there a way that I can use a function instead of calling “withdraw” like this Withdraw from cookie consent which will withdraw from all cookies except necessary at once ? So that I can just call withdraw for a particular cookie like marketing ?

    Plugin Author cookiebot

    (@cookiebot)

    @pramakrishna

    Can you verify that you have added a Cookiebot ID in the Cookiebot WordPress plugin? If you do not add an ID, uc.js will not be rendered on your page, and thus the Cookiebot object will not be available. By looking at your sample code, there is no Cookiebot ID.

    You can add your staging domain (localhost, 127.0.0.1) or whatever you use as an alias in the Manager, which is free of charge. For more information on test domains, have a look here: https://support.cookiebot.com/hc/en-us/articles/360003794134-Why-is-the-cookie-consent-banner-dialog-not-showing-on-my-website-

    • This reply was modified 6 years, 4 months ago by cookiebot.
    Thread Starter pramakrishna

    (@pramakrishna)

    Each and everything is fine… the banner is working and I am also displaying the full description inside my cookie page with table description. And all that is fine.

    <script id=”Cookiebot” src=”https://consent.cookiebot.com/uc.js” data-cbid=”” type=”text/javascript” async=””></script>

    And in the above tag, I havent purposefully added the data-cbid since its private. But yes I have added the Cookiebot ID too inside my wordpress.

    Its just that I am getting an error for this line “Cookiebot.consent.marketing” when I compile my code and I am trying that functionality where a user can opt-out or opt-in from a particular cookie (say marketing or statistics) with a “button” and not “checkbox”.

    So can you suggest me if there is any particular solution for that ?

    Plugin Author cookiebot

    (@cookiebot)

    @pramakrishna

    Its just that I am getting an error for this line “Cookiebot.consent.marketing” when I compile my code and I am trying that functionality where a user can opt-out or opt-in from a particular cookie (say marketing or statistics) with a “button” and not “checkbox”.

    Before we go into creating different templates for the banner, we should get that event handler working.

    Once uc.js (Cookiebot) is added to the DOM, the Cookiebot object is accessible globally. The code you have supplied for the event handler looks correct, however, for some reason, it can’t reach the Cookiebot object, thus giving you an error.

    In order to proceed debugging this issue, you’ll have to supply us with a link, or recreate the issue on an environment that is accessible to us.

    And in the above tag, I havent purposefully added the data-cbid since its private.

    The data-cbid is available for all your visistors.

    Thread Starter pramakrishna

    (@pramakrishna)

    Hi,

    This is the site where we are currently using the banner template as checkboxes.

    https://sportradar.com/about-us/cookies/

    But in the places inside the table detail description of the cookies where there are red button called “Change your cookie consent”, we want to add a button called “opt-in” or “opt-out” which gives the user an option to withdraw from one particular cookie like marketing and not withdraw from all cookies at once.

    And use the banner template as just “allow all cookies” and not checkboxes.

    Plugin Author cookiebot

    (@cookiebot)

    @pramakrishna

    If you were to add the event listener mentioned above, to the page that you link to, it should work.

    Can you reproduce the

    “Cookiebot” is not defined

    issue?

    As for your other question, it is currently only possible to control a users consent through the banner, so unfortunately there is no easy way of creating a custom implementation, where the banner is a full-opt in, and the “Change your cookie consent” is a custom implementation, giving the user the ability to opt-in to specific categories (by not using the banner).

    • This reply was modified 6 years, 4 months ago by cookiebot.
    Thread Starter pramakrishna

    (@pramakrishna)

    Yes I found out another solution to overcome “Cookiebot” is not defined error. So that is ok.

    Can you please tell me how I can withdraw from a particular Cookie(eg say Marketing) on button click ??

    And at the same time accept the consent to “true“ for a particular Cookie like Marketing on button click ??

    Currently there is one function which withdraws from all cookies

    Can you let me know whether that’s possible ?? Or as you mentioned above, isn’t that not possible as well ??

    Plugin Author cookiebot

    (@cookiebot)

    @pramakrishna

    The Cookiebot API does not support that currently. You can read consent from it. If you want to change a users consent, you’ll have to use the Cookiebot.renew(); function, which pops up your banner. In future releases, we may add the opportunity to change consent, without having to use the banner. Thanks for your understanding and patience.

    Plugin Author cookiebot

    (@cookiebot)

    @pramakrishna We have updated our API to support your needs.

    Instead of using the banner to change consent, you can call:

    Cookiebot.submitCustomConsent(optinPreferences, optinStatistics, optinMarketing)

    Where optinPreferences, optinStatistics, optinMarketing are bool values.

    If you only want to change one consent category, you can retrieve what the user has already selected for the other categories, through the Cookiebot object.

    Cookiebot.consent.preferences
    Cookiebot.consent.statistics
    Cookiebot.consent.marketing

    Hope this helps!

    Thread Starter pramakrishna

    (@pramakrishna)

    Hi,

    Thanks for the quick update. Could I use the Cookiebot submit consent like this ?

    <p style=""><button style="border:unset;display:flex;background:rgb(49, 49, 49) !important;"><a href="javascript: Cookiebot.submitCustomConsent(true, true, true)" style="color:#e7e738;">Change your cookie consent</a></button></p>
    <p style=""></p>
    Thread Starter pramakrishna

    (@pramakrishna)

    Hi,

    Actually I found out another solution using the one you mention above

    Cookiebot.consent.preferences
    Cookiebot.consent.statistics
    Cookiebot.consent.marketing
    

    So, here I added some code of my own inside the Cookiebot dashboard having cookie declaration and consent dialog

    <p style=""><button class="cookiechange" style="border:unset;display:flex;background:rgb(49, 49, 49) !important;"><a href="javascript:void(0);" style="">Change your cookie consent</a></button></p>
    <p style=""></p>

    So my idea was to change the cookie consent of the user on click of the button having the class == cookiechange

    And I gave the function for it inside my javascript file. But I see that we cannot use our own function call. Something like this:

    <script type="text/javascript">
       $( document ).ready(function() {
         $('.CookieDeclarationType .cookiechange').on("click", function(e) {
                e.preventDefault();
                console.log("Execute code that sets marketing cookies");
                if (Cookiebot.consent.marketing)  {
                    console.log("Marketing is true", Cookiebot.consent.marketing);  
                     Cookiebot.consent.marketing = false;
                     console.log("Marketing is false now", Cookiebot.consent.marketing);  
                     Cookiebot.submitCustomConsent(true, true, false);
              }
          });
      });
    </script>

    Is that true we cannot use our own function call from the dashboard to our javascript file??

    Thread Starter pramakrishna

    (@pramakrishna)

    Hi,

    Finally the above 2 problems were solved. But there is a drawback in the update provided:

    Suppose I have 2 button as options for the user to Opt-in and Opt-out for Statistics cookies:

    Opt-in Cookiebot.submitCustomConsent(true,true,false)
    Opt-out Cookiebot.submitCustomConsent(true,false,false)

    And in the same way below for Marketing cookies

    Opt-in Cookiebot.submitCustomConsent(true, true, true)
    Opt-out Cookiebot.submitCustomConsent(true, true, false)

    In the above options, you can see that the user will have a confusion, when he has opted-out from “Statistics” cookies and still wants to be opted-in for Marketing cookies, then its not possible with 2 combinations of buttons. I will have to create 4 combinations for him to select. Because this update is similar to the function “withdraw” which withdraws from all cookies at once and this function “submitCustomConsent” requires parameters to be passed for all cookies at once and not for separate cookies.

    Is it possible to create separate opt-out functions as per cookies than having 3 cookies inside one function called “submitCustomConsent” like Submit marketing consent, Submit Statistics content ?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Adding script inside your code to customize the plugin as per development page’ is closed to new replies.