Last active
January 27, 2022 12:46
-
-
Save alexiglesias93/8994a7be86dbab7912bebeba9a2b05a6 to your computer and use it in GitHub Desktop.
fs-cc-consents
This file contains 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
// Leer los consents existentes actualmente: | |
let currentConsents = window.FsCC.store.getConsents(); | |
//Los consents están en el siguiente formato: | |
/* | |
currentConsents = { | |
analytics: false, | |
essential: true, | |
marketing: false, | |
personalization: false, | |
uncategorized: false, | |
}; | |
*/ | |
// Donde `true` define si el consentimiento está aceptado. | |
// Al registrar este event listener, el callback se llama cada vez que el usuario modifica sus consentimientos. | |
window.FsCC.consentController.on('updateconsents', () => { | |
// Leer los consents de nuevo: | |
currentConsents = window.FsCC.store.getConsents(); | |
console.log('Los nuevos consents son:'); | |
console.log(currentConsents); | |
// Hacer lo que sea con los nuevos consents... | |
}); |
This file contains 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
/** | |
* Para asegurarse que `window.FsCC` está cargado: | |
* Añadir un selector al script. Ejemplo: | |
* <script async id="fs-cc" src="https://cdn.jsdelivr.net/npm/@finsweet/cookie-consent@1/fs-cc.js" fs-cc-mode="opt-in"></script> | |
*/ | |
function randomLogic() { | |
console.log('Accessing FsCC...'); | |
} | |
if (window.FsCC) randomLogic(); | |
else document.getElementById('fs-cc').onload = randomLogic; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment