Events
Lawwwing dispatches events on document that you can listen to in order to react to the user's consent and to the banner loading.
The Lawwwing script must be loaded on the page. See the SDK reference to learn how to integrate it.
lawwwing:consent:ready​
This event is triggered when user consent is ready, either because it has just been submitted or loaded from an existing cookie. Listen to this event if you need to retrieve user consent and run additional scripts as soon as possible based on consent values.
The event returns a CustomEvent object with a detail property that contains the consent object with the user's consent values.
| Property | Type | Description | Values |
|---|---|---|---|
consent.technical | boolean | Consent value for the technical category. | true or false |
consent.preferences | boolean | Consent value for preferences. | true or false |
consent.marketing | boolean | Consent value for marketing. | true or false |
consent.analytics | boolean | Consent value for analytics. | true or false |
This event will be emitted whenever consent is available, even if the user has not interacted with the banner (for example, if consent was previously granted).
Usage Example​
document.addEventListener('lawwwing:consent:ready', function(event) {
if (event.detail.consent.marketing) {
// Run additional scripts when the marketing category is allowed
}
});
lawwwing:ui:ready​
This event is triggered when the consent banner UI is fully loaded and ready for interaction. Listen to this event if you need to run UI-related actions, such as customizing its appearance or behavior.
document.addEventListener('lawwwing:ui:ready', function() {
// The consent banner UI is ready
// For example, open the legal notice automatically
Lawwwing.sdk.document('notice').open();
});