More and more jurisdictions in the world have requirements regarding the handling of users' personal data, known as personally identifiable information or PII. Because of this, you may need to prompt your users to consent or decline to being tracked.
In addition to the typical practice of tracking via cookies, there's only one way users are tracked in Higher Logic Vanilla:
- through our Vanilla Analytics feature, which you can opt a user out of by setting the JavaScript variable
gdn.meta.AnalyticsTask
to false
on every page load for anyone who does not consent to be tracked.
While there's no way to achieve this with a simple click of a button, you can leverage custom JavaScript in our Style Guide (or a custom HTML Pocket) to build your own solution. Some communities have done this is by placing a script in the JavaScript tab of their Style Guide to check if the user has consented or not, and then turn off the Analytics tracker for that person:
// This is not tested code. For demonstration purposes only.
// Add a function to read the cookie.
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
// Set it so that analytics won't track the user.
gdn.meta.AnalyticsTask=false;
// Check if the user has given consent.
let cookieConsent = getCookie('consent');
// If the user has given consent set the track to track them.
if (cookieConsent) {
gdn.meta.AnalyticsTask='tick';
}
In a custom HTML Widget in the Layout Editor (or a custom HTML Pocket), build out a JavaScript button that, when submitted sets the consent cookie:
document.cookie = 'consent=true;domain=.[your-domain];path=/';
📝 NOTE: The %-vA
cookie, the Vanilla Analytics cookie, will still be set, only now it is not tracking anything.