Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created April 28, 2026 08:37
Show Gist options
  • Select an option

  • Save webtoffee-git/640b4476a4b63cc954be95101b3a3a52 to your computer and use it in GitHub Desktop.

Select an option

Save webtoffee-git/640b4476a4b63cc954be95101b3a3a52 to your computer and use it in GitHub Desktop.
check whether the user has already consented in a previous session and act accordingly - By WebToffee
document.addEventListener("_wccBannerVisible", function (event) {
const consentData = getWccConsent();
// Check stored analytics consent
if (consentData.categories.analytics === true) {
console.log("Analytics consent is YES (true).");
// Load analytics scripts
} else {
console.log("Analytics consent is NO (false).");
// Do not load analytics scripts
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment