Setting Up a DNT Tag for Brainfish AI Agent
1min read
By default, Brainfish agents do not use cookies to track users, we use a cookie-less approach to ensure GDPR compliance.
However, if you’d like to setup a specific Do Not Track (DNT) request using a cookie handler like CookieBot or CookiePro that will disable session recordings, and ambient knowledge for certain users that have not opted in to cookies, here is how to do so:
Setup
To disable tracking (stops recording, screenshots, etc.) when cookies are not accepted, use the following code within your cookie handler:
window.BrainfishAnalytics('disableTracking');
// To re-enable tracking (requires a page reload for full effect)
window.BrainfishAnalytics('enableTracking');
// To check if tracking is currently disabled
const isDisabled = window.BrainfishAnalytics('isTrackingDisabled');
console.log('Is tracking disabled?', isDisabled); // true or false
Real World Example of DNT handler set up to disable session recording
// When user clicks "Accept All" on cookie banner
document.getElementById('accept-all').addEventListener('click', () => {
window.BrainfishAnalytics('enableTracking');
// Store consent preference
localStorage.setItem('cookie-consent', 'all');
// Reload page to restart recording
window.location.reload();
});
// When user clicks "Reject Optional" on cookie banner
document.getElementById('reject-optional').addEventListener('click', () => {
window.BrainfishAnalytics('disableTracking');
// Store consent preference
localStorage.setItem('cookie-consent', 'essential-only');
});
// On page load, check existing consent
if (localStorage.getItem('cookie-consent') === 'essential-only') {
window.BrainfishAnalytics('disableTracking');
}
