Do Not Track Option

If you wish to track the visitor numbers, without persisting their information over the session then you can fire Cubed tag where Cubed will not save any cookies in the browser. For this, we need the client to load the base tag whether the cookie is selected or not and set banner_accepted cookie to 0. Now, Cubed will fire the tag without saving any cookies and each visitor is considered a new visitor. This has particular use case such as tracking right number of landing page referrers.

After you configure to fire tag without saving cookies, you should also configure to fire with cookie when the cookies are accepted. For which, you should set the banner_accepted cookie to 1 when the cookie banner is accepted. Now, the cookies will persist over the session.

A code example

Below we have an implementation code for WIX website.

<script>
    function getCookie(cname) {
        let cookies = document.cookie.split(';');
        for (const cookie of cookies) {
            const [name, value] = cookie.split('=');
            if (name.trim() === cname) {
                return decodeURIComponent(value);
            }
        }
        return '';
    }

    function setCookie(cname, cvalue, exdays) {
        const d = new Date();
        d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
        const expires = 'expires=' + d.toUTCString();
        document.cookie = cname + '=' + encodeURIComponent(cvalue) + ';' + expires + ';path=/';
    }


    const intervalId = setInterval(() => {
        /*
            This function polls to check if the cookie banner is selected.
            WIX set 'consent-policy' cookie on accepting the cookie banner.
            There will certainly be better option than this, such as adding the
            logic to set banner_accepted in the same place that handles the 
            website's cookie.
        */
       if(getCookie('banner_accepted')===''){
            // set banner_accepted to 0 with expiry days of 10
            setCookie('banner_accepted', 0, 10)

            // Inject base tag
            var script = document.createElement("script"); 
            script.type = "text/javascript"; 
            script.async = true; 
            script.src = "https://cubed-custom-tags.s3.eu-west-1.amazonaws.com/visscore.tag.js"; 
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(script, s); 
            window.vscr = window.vscr || [];

            // Set account token and fire
            vscr.push(["setAccount", "<account_token>"]); 
            vscr.push(['fire'])
       }
        if (getCookie('consent-policy') && JSON.parse(getCookie('consent-policy')).func === 1) {
            setCookie('banner_accepted', 1, 30);
            clearInterval(intervalId);
        }
    }, 5000);


</script>

Code Explanation

We have defined getCookie and setCookie functions which take arguments such as cookie name(cname), cookie value(cvalue), expiry day(exdays). The code above is continuously checking if the banner is selected or rejected. This logic may vary according to the cookie implementation in the website that is being tagged. For Wix, we needed to check consent-policy cookie and if func value is 1 then we can say cookie has been selected and we can set banner_accepted cookie in this case and we can exit out of the polling process. If the cookie is not selected we should set banner_accepted cookie to 0. In this mode Cubed will fire tag without tracking visitors.

The tag is stored in S3 which can be accessed via url https://cubed-custom-tags.s3.eu-west-1.amazonaws.com/visscore.tag.js.

The implementation may vary here, particularly the polling code. It's purpose is mostly for demonstration. Best recommendation for implementing do not track option is to implement banner_accepted cookie in the same handler that handles cookie of the website.