Skip to main content
Version: v1.5.4

Developers

This section is designed to help you efficiently and securely integrate, customize, and extend the functionalities of Lawwwing.

Here you'll find API references, code examples, and best practices to make the most out of our platform.

If you're looking for a basic guide to get started with the default Lawwwing implementation, you can find it here.

This section documents our SDK, which allows you to create custom implementations of the consent banner and cookie controls. It also includes options for manually overriding the automated behavior of the consent banner.

Important: To ensure the SDK works properly, the Lawwwing script must be integrated into your website.

You can integrate the Lawwwing script as follows:

<!-- Lawwwing plugin for https://your-web.com -->
<script src="https://cdn.lawwwing.com/widgets/current/<your-client-id>/cookie-widget.min.js" type="text/javascript" data-lwid="<your-client-id>"></script>
warning

This code is just an example; you'll find your own within your control panel.

Once loaded, the script generates a JavaScript object on the client called Lawwwing, which exposes the following properties, public methods, and events to facilitate advanced integration.


Custom Events

lawwwing:consent:ready

This event is triggered when the user's consent is ready, either because it has been submitted or loaded from an existing cookie. Listen to this event if you need to retrieve the user's consent and execute additional scripts as soon as possible based on the consent values.

The event returns a CustomEvent object with the detail property containing the consent object with the user's consent values.

PropertyTypeDescriptionValues
consent.technicalbooleanConsent value for the technical category.true or false
consent.preferencesbooleanConsent value for preferences.true or false
consent.marketingbooleanConsent value for marketing.true or false
consent.analyticsbooleanConsent value for analytics.true or false

Usage Example

document.addEventListener('lawwwing:consent:ready', function(event) {
if (event.detail.consent.marketing) {
// Execute additional scripts with marketing category allowed
}
});

Public Methods

In Lawwwing, user consent is managed through a layered system that allows for a more flexible experience.

  • Layer 1: Main consent banner. This is the initial message informing the user about cookie usage and requesting them to accept or configure their preferences.
  • Layer 2: Advanced configuration panel. This allows the user to select in more detail which cookie categories they wish to accept or reject.

The Lawwwing SDK provides public methods to manually show or hide these layers, ideal if you want to control the user experience from your application or website.


Lawwwing.sdk.show(layer)

This method allows you to manually display one of the consent banner layers.

Parameters

ParameterTypeDescription
layerintLayer number to display. Use 1 for the main banner and 2 for the configuration panel.

Examples

// Show the first layer: Consent banner
Lawwwing.sdk.show();
// Show the first layer: Consent banner
Lawwwing.sdk.show(1);
// Show the second layer: Advanced configuration
Lawwwing.sdk.show(2)

Lawwwing.sdk.hide(layer)

This method allows you to manually hide one of the consent banner layers.

Parameters

ParameterTypeDescription
layerintLayer number to hide. Use 1 for the main banner and 2 for the configuration panel.

Examples

// Hide the first layer: Consent banner
Lawwwing.sdk.hide();
// Hide the first layer: Consent banner
Lawwwing.sdk.hide(1);
// Hide the second layer: Advanced configuration
Lawwwing.sdk.hide(2)
tip

You can combine these methods with SDK events or custom buttons in your interface to provide a smoother and more user-friendly consent experience.