Developers
NAV Navbar
  • Opt-out Cookie
  • Opt-out Cookie

    Context

    Kameleoon default tracking does not include any personal data. All results are anonymized and reports are provided without any personal data. Still, many countries provide laws that make it mandatory for analytical platforms such as Kameleoon to allow visitors the option to never be tracked at all. In order to comply with those laws, Kameleoon has an option to entirely disable tracking, on a per user basis. Technically, the presence of a given cookie on the user's browser will block Kameleoon tracking (and only Kameleoon tracking - no other solutions are disabled).

    Technical description

    Name of cookie: kameleoonOptout
    Value: true
    Duration: custom (according to your requirements)
    Domain: underlying domain of the web page where Kameleoon script is installed (the cookie is read in JavaScript)
    

    Kameleoon's engine will automatically attempt to read this cookie at initialization, and if it is present, will abort setup for this particular visitor (disabling itself entirely).

    Note that apart from writing custom JavaScript (or server-side) code to set the cookie, we provide another easy way to automatically create the opt-out cookie. If you add the query parameter #kameleoonOptout=true at the end of any page where Kameleoon script is installed, Kameleoon's code will automatically create the opt-out cookie with a default duration of 45 days.

    Example

    <script>
        function acceptPolicy() {
            document.getElementById('footer').style.visibility = 'hidden';
        }
    
        function doNotTrack() {
            const expiryDate = new Date();
    
            expiryDate.setMonth(expiryDate.getMonth() + 1);
            document.cookie = 'kameleoonOptout=true; expires=' + expiryDate.toGMTString();
            document.getElementById('footer').style.visibility = 'hidden';
        }
    </script>
    <div id='footer'>
        <p>
            We use cookies to personalise content and to analyse our traffic.
            Please accept if you comply with our privacy policy
            or decline if you wish to avoid tracking.
        </p>
        <button type='button' onclick="acceptPolicy()">Accept</button>
        <button type='button' onclick="doNotTrack()">Decline</button>
    </div>
    

    On the right we provide a simple example, where our customer's privacy policy includes the ability for a visitor to opt-out of Kameleoon tracking. Therefore the customer provides a dialog that warns its visitors that some information may be tracked for personalization purposes. If they don't agree with such terms, they can avoid tracking by clicking the appropriate button.

    As the example shows, we create a cookie named kameleoonOptout with its value equal to true. The expiry date indicates when the cookie shall be removed by a browser, therefore re-enabling the Kameleoon application. The expiry date can be set based on your requirements (mainly this will depend on the laws of your country). Note that in the example on the right, the opt-out cookie is created for one month.