API & SDK

SDK Script Tag Attributes

Last updated March 5, 2026

SDK Script Tag Attributes

The LegalBanner SDK is configured through data-* attributes on the script tag.

Required Attributes

| Attribute | Description | |-----------|-------------| | data-site-id | Your site's unique identifier (UUID). Found in the dashboard under Sites. |

Optional Attributes

| Attribute | Default | Description | |-----------|---------|-------------| | async | - | Load the script asynchronously (recommended) | | defer | - | Alternative to async; loads after HTML parsing |

Tag Governance Attributes (on wrapped scripts)

When using Loader mode, third-party scripts are wrapped with these attributes: | Attribute | Description | |-----------|-------------| | type="text/plain" | Prevents the browser from executing the script | | data-lb-tag | The vendor key from the Tag Registry (e.g., google-analytics) | | data-lb-category | The consent category (e.g., analytics, marketing, functional) | | data-src | The original src URL (used when the script is activated) |

Example: Full Configuration

``html `

How the SDK Loads

1. The script tag is parsed by the browser 2. The SDK fetches configuration from
/api/sdk/config?site_id=YOUR_SITE_ID` 3. The configuration includes banner settings, consent categories, and (for Pro) enforcement policies 4. The SDK renders the consent banner in a Shadow DOM container 5. On consent interaction, the SDK updates consent signals and activates approved scripts