Created
April 28, 2026 08:36
-
-
Save webtoffee-git/03a096520d742a6de4f19f9e1ca3f52f to your computer and use it in GitHub Desktop.
Execute or suppress a script immediately after the user makes a consent choice - By WebToffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener("wcc_consent_update", function (eventData) { | |
| const categories = eventData.detail.categories; | |
| // Check if the analytics category was accepted | |
| if (categories && categories.accepted && categories.accepted.includes('analytics')) { | |
| console.log('Analytics consent: GRANTED'); | |
| // Initialize your analytics script here | |
| } else { | |
| console.log('Analytics consent: DENIED'); | |
| // Suppress or remove your analytics script here | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment