If your Higher Logic Vanilla (Vanilla) community is using analytics, each user's activity is tracked for analytics reporting to provide your organization with important engagement metrics.
- This activity is tied to each user based on their user name and user ID.
- While this specificity is helpful, there may be cases where your organization does not want user activity to be tracked in this manner.
In this article, you'll learn the two ways your organization can anonymize analytics data in Vanilla. Anonymization can be achieved:
- globally with the site-wide default option
- and/or on a per-user basis via a third-party consent form.
Before we begin…
Keep the following important notes in mind regarding analytics anonymization:
- Anonymization is not retroactive. When enabled, data anonymization will occur from that point forward.
- All user activity is still tracked, even if you choose to anonymize analytics data; it will simply no longer be tied to a user's user name or user ID. In other words, you'll still be able to report on engagement metrics but lose the specificity of knowing who is performing the activity.
Global anonymization
Your organization can set a site-wide default to control whether analytics data is globally anonymized or not. Let's walk through how to turn this setting on/off.
- Access the Dashboard.
- Navigate to Settings > Membership > User Preferences.
- Click to turn the Anonymize Analytics Data by Default toggle on/off.
📝 NOTE: If your organization also has a consent form, this value will be the default for users who have not interacted with it.
Third-party consent form
While the site-wide option is perfect if your organization wants all user analytics data anonymized by default, another option is to integrate your Vanilla community with a third-party vendor to display a consent form. This presents each user with a digital form in your community giving them the choice whether they want their data anonymized or not.
🛑 IMPORTANT: Setting up a consent form is a technical process that is meant for developers and users with the technical expertise to modify websites via JavaScript. Please request the help of a developer if you're unsure how to implement the JavaScript in this section.
The following methods are available via the onVanillaReady
function to integrate third-party consent forms, such as CookieYes, with our API to display the form in your community.
getAnonymizeData()
will return a Promise with a boolean value for the current user.- This value is set by using the
setAnonymizeData()
method. - If the user is a guest and a value does not exist in cookies, the site default will be returned.
- If the user has not yet set this value, the site default will be returned.
- If the user has set this value via the consent form, that value will be returned.
- The returned value is the user's preference for anonymize data in analytics.
true
: Anonymize the user's data in analyticsfalse
: Do not anonymize the user's data in analytics
setAnonymizeData(value?: boolean)
will set the user's preference to anonymize data and return a Promise with the new value.- The value is optional. If it is not provided, the user will be set to use the site's default value.
undefined
: Use the site's default value for AnonymizeData.
true
: Anonymize the user's data in analytics.false
: Do not anonymize the user's data in analytics.
- If the user is a guest, a cookie will be set with the selected value.
- This cookie will be removed and saved to the user's record on login.
- Cookie name is the site's cookie name prefix that can be set in the config
Garden.Cookie.Name
, followed by -AnonymizeData
. The default cookie name is "Vanilla," so by default the cookie name will be "Vanilla-AnonymizeData."
Each third-party integration will be different based on their available functionalities. Below is an example getting the analytics value from the form once it has been changed and saving the preference to the user's record.
📝 NOTE: If a user is not logged in, the value is saved to a cookie. The cookie is removed once the user has logged in.
Consent form example
In this example, we'll look at setting up a consent form via CookieYes.
- Visit
https://www.cookieyes.com/
and create a banner.
- You will be given an installation code (you only need the
src
value). - Access the Dashboard and navigate to Appearance > Style Guides to access your list of Themes.
- Edit your Theme and click the Javascript tab.
- Add the following snippet into the Javascript, replacing the URL with the one from your installation code.
function injectFile(validUrl, id) {
const nonce = document.querySelector("script")?.nonce;
const head = document.querySelector("head");
const scriptTag = document.createElement("script");
scriptTag.setAttribute("nonce", nonce);
scriptTag.setAttribute("type", "text/javascript");
if (id !== undefined && id) {
scriptTag.setAttribute("id", id);
}
scriptTag.async = true;
scriptTag.src = validUrl ? validUrl : "";
head.appendChild(scriptTag);
};
onVanillaReady(async function (e) {
injectJSFile([URL_from_installation_script], "cookieyes");
document.addEventListener("cookieyes_consent_update", async function (eventData)
{
// If the analytics cookie is not accepted, the user is requesting to have
// their data anonymized. Check if "analytics" is in the rejected list
const cookieAnalyticSet = eventData.detail.rejected.includes("analytics");
await e.setAnonymizeData(cookieAnalyticSet);
});
});
Dev console
You can also access these functions via your browser's dev console and return the result.
Add the following snippet to get the user's preference:
onVanillaReady(async function(e) {const isAnonymized = await e.getAnonymizeData();console.log(isAnonymized);});
To set the preference from the dev console manually, use the following snippet:
onVanillaReady(async function(e) {const isAnonymized = await e.setAnonymizeData(false);console.log(isAnonymized);});