Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Pop Up when using cookies

Is there a way to have a message pop up at the beginning of a survey if cookies have been enabled in the survey?
asked Aug 27, 2018 by Jay Rutherford Gold (38,005 points)

1 Answer

0 votes
This script should show HTML elements with the class "cookieText" only when cookies are enabled.

$(document).ready(function(){
    $('.cookieText').toggle(navigator.cookieEnabled);
})
answered Aug 27, 2018 by Zachary Platinum Sawtooth Software, Inc. (156,150 points)
I'm not sure I understand how to use this.  Within Lighthouse, there is the settings option to use a cookie-based restart.  I assumed that was the only time cookies were being used, or are cookies always being used?  When that was enabled I was hoping to have a pop up at the beginning to let the respondent know that cookies are being used.  I had a request in dealing with GDPR compliance to have this.
Before I go on, I should state that I am not a lawyer nor any form of expert on GDPR.  All I have done is read a quick review of GDPR's cookie requirements and performed examinations on how Lighthouse Studio v9.6.1 uses cookies.  My advice should not be interpreted as a guarantee of compliance with GDPR.

That being said, it appears the GDPR does not recognize messages akin to "by using this site, you accept cookies" as compliance.  Instead, users must have clear options to accept or reject cookies.

In my investigation of Lighthouse's behavior, cookies are only saved if the "Use cookies" checkbox is selected in the questionnaire's password settings and only immediately after the respondent submits the start page of the questionnaire.  Cookies are not read from or written to at any other time.  This seems to suggest that the easiest way to make a Lighthouse Studio study compliant with GDPR would be to keep users from continuing past the start page until accepting the use of cookies.  Try adding this to your start question:

<div id="cookieAcceptanceOverlay">
    <div id="cookieAcceptanceDialog">
        <div>This website uses cookies to ensure you get the best experience.</div>
        <br/>
        <button id="cookieAccept">Accept Cookies</button>
    </div>
</div>

<style>
#cookieAcceptanceOverlay {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 9999;
    background-color: #000;
    opacity: 0.5;
}

#cookieAcceptanceDialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 33%;
    max-width: 400px;
    background-color: white;
    opacity: 1;
    border: 1px solid black;
    border-radius: 8px;
    padding: 8px;
}

#cookieAccept {
    cursor: pointer;
    padding: 8px;
}
</style>

<script>
$(document).on('click', '#cookieAccept', function(){
    $('#cookieAcceptanceOverlay').remove();
})
</script>
Thank you for the thoughtful response Zach.  This definitely helps.  At least I know exactly where, how and when cookies are used.  Clearly, to be compliant we would need to avoid using a 1-click link on a study where cookies were enabled as that bypasses the start screen and thus already used cookies.  With a standard survey access link this will work.  I can at least now have more of an open dialogue based on each project's needs.

Thanks again!
...