Created
January 22, 2026 14:38
-
-
Save hjanuschka/64e0f9fdc7dd5280fa49fabc281f1ddc to your computer and use it in GitHub Desktop.
Didomi Consent Gate - Load scripts only when vendor 755 + purpose 1 (cookies) are consented
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
| /** | |
| * Didomi Consent Gate | |
| * Loads scripts only when vendor 755 + purpose 1 (cookies) are consented | |
| */ | |
| (function() { | |
| var scriptsLoaded = false; | |
| function loadScripts() { | |
| if (scriptsLoaded) return; | |
| scriptsLoaded = true; | |
| // === ADD YOUR SCRIPT LOADING HERE === | |
| // var script = document.createElement('script'); | |
| // script.src = 'https://example.com/your-script.js'; | |
| // document.head.appendChild(script); | |
| console.log('Consent granted - loading scripts...'); | |
| } | |
| function checkConsent(Didomi) { | |
| var hasConsent = Didomi.getUserConsentStatusForVendor('755') && | |
| Didomi.getUserConsentStatusForPurpose('1'); | |
| if (hasConsent) loadScripts(); | |
| } | |
| // Check on initial load | |
| window.didomiOnReady = window.didomiOnReady || []; | |
| window.didomiOnReady.push(checkConsent); | |
| // Check on consent change | |
| window.didomiEventListeners = window.didomiEventListeners || []; | |
| window.didomiEventListeners.push({ | |
| event: 'consent.changed', | |
| listener: function() { | |
| if (window.Didomi) checkConsent(window.Didomi); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment