Cookie Control Callbacks


You can be notified when cookie settings are changed either by creating a global function with the name TruendoCookieControlCallback or by adding a listener for the TruendoCookieControl event to window.

Callback example

 1<script type="text/javascript">
 2  function TruendoCookieControlCallback(cookieSettings) {
 3    if (cookieSettings.ack) {
 4      console.log('Cookie dialog acknowledged');
 5    }
 6    if (cookieSettings.necessary) {
 7      console.log('Necessary cookies enabled.');
 8    }
 9    if (cookieSettings.preferences) {
10      console.log('Preference cookies enabled.');
11    }
12    if (cookieSettings.statistics) {
13      console.log('Statistics cookies enabled.');
14    }
15    if (cookieSettings.marketing) {
16      console.log('Marketing cookies enabled.');
17    }
18  });
19</script>

Event listener example

 1<script type="text/javascript">
 2  window.addEventListener('TruendoCookieControl', function (event) {
 3    // cookie settings accessible via event.detail
 4    var cookieSettings = event.detail;
 5    
 6    if (cookieSettings.ack) {
 7      console.log('Cookie dialog acknowledged');
 8    }
 9    if (cookieSettings.necessary) {
10      console.log('Necessary cookies enabled.');
11    }
12    if (cookieSettings.preferences) {
13      console.log('Preference cookies enabled.');
14    }
15    if (cookieSettings.statistics) {
16      console.log('Statistics cookies enabled.');
17    }
18    if (cookieSettings.marketing) {
19      console.log('Marketing cookies enabled.');
20    }
21  });
22</script>

In addition to receiving the cookie settings within a callback or event listener, you can access the cookie settings at any time via the read-only Truendo.cookieSettings property.