Skip to main content
Version: v1.9.5

Developers

This section is designed to help you integrate, customize, and extend Lawwwing features efficiently and safely. Here you will find API references, code examples, and best practices to get the most out of our platform.

If you are 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 describes the available options for manually overriding the consent banner's automated mechanisms.

Important: For the SDK to work correctly, 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 only an example; you will find your own in your control panel.

Once loaded, the script creates a client-side JavaScript object called Lawwwing, which exposes the following properties, public methods, and events to support advanced integrations.


Custom Events

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.

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
note

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();
});

Public Methods (SDK)

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

  • Layer 1: Main consent banner. This is the initial message that informs the user about cookie usage and asks them to accept or configure their preferences.
  • Layer 2: Advanced settings panel. This allows the user to choose in more detail which cookie categories they want to accept or reject.

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


Lawwwing.sdk.show(layer)

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

Parameters

ParameterTypeDescription
layerintLayer number to show. Use 1 for the first layer and 2 for the settings 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 settings
Lawwwing.sdk.show(2)

Lawwwing.sdk.hide(layer)

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

Parameters

ParameterTypeDescription
layerintLayer number to hide. Use 1 for the main banner and 2 for the settings 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 settings
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.


In addition to showing or hiding widget layers, the SDK lets you accept, deny, or update user consent from your own interface. These methods reuse the widget's internal flow, so they save state and trigger the corresponding consent events.

note

Use these methods only after the Lawwwing script has been initialized on the page.

Lawwwing.sdk.accept()

Accepts all available consent categories.

Example

// Accept all consent from a custom button
Lawwwing.sdk.accept();

Lawwwing.sdk.deny()

Deny all optional categories and keep only the required categories active.

Example

// Deny all optional categories
Lawwwing.sdk.deny();

Lawwwing.sdk.update(categories)

Updates consent at a granular category level.

Parameters

ParameterTypeDescription
categoriesobjectObject with categories to update. Each key must be a valid category and each value must be true or false.

Common Categories

CategoryTypeDescription
technicalbooleanTechnical or strictly necessary cookies.
preferencesbooleanUser preferences and personalization.
analyticsbooleanMeasurement and analytics.
marketingbooleanAdvertising and commercial tracking.

Examples

// Allow analytics and disable marketing
Lawwwing.sdk.update({
analytics: true,
marketing: false,
});

// Keep only required categories and preferences
Lawwwing.sdk.update({
technical: true,
preferences: true,
analytics: false,
marketing: false,
});
tip

Lawwwing.sdk.update(categories) only applies the categories included in the provided object, so you can update one or several without resending the full state.

info

The methods Lawwwing.sdk.accept(), Lawwwing.sdk.deny(), and Lawwwing.sdk.update(categories) trigger the consent flow and return control immediately. They do not wait for all integrations or subsequent processes to finish before execution continues.


Lawwwing.sdk.document(document)

This method lets you access Lawwwing documents from your application or website.

You can use it to display any document that is active in your Lawwwing account.

warning

For the viewer to work properly, you must have an active subscription in your Lawwwing account.

Parameters

ParameterTypeDescription
documentstringType of document to display. Options: notice privacy terms, cookies, or purchase.
tip

The available document types may vary depending on your subscription plan.

Examples

// Open legal notice
Lawwwing.sdk.document('notice').open();
// Close legal notice
Lawwwing.sdk.document('notice').close();
// Open privacy policy
Lawwwing.sdk.document('privacy').open();
// Close privacy policy
Lawwwing.sdk.document('privacy').close();