Quickstart
Get a compliant banner live in about a minute. First, choose the tag setup that
matches your site in Choose your setup or use the
Lightning configurator. The final
lightning("init", …) line depends on that choice.
Before you start
Section titled “Before you start”You need three things — see Prerequisites for detail:
- A license key (
k=8f3c…). It’s baked into the script URL and carries yoursiteId, so you usually don’t setsiteIdininit(). - Your domains registered against the site. The SDK only runs on authorised
hosts; everywhere else it’s a harmless no-op (
localhostis allowed for testing). - Access to
<head>— ideally as the first thing in it.
Install
Section titled “Install”The head block depends on who owns Google Consent Mode. When you use a Google bridge, the bridge supplies the default and the snippet stays smaller. Choose the setup before you paste it:
Use this when your tags are managed in GTM. Replace GTM-XXXXXXX with your
container ID, then configure each tag’s Consent Settings in GTM.
<!-- 1. Warm up the first backend round-trip. --><link rel="preconnect" href="https://cmp.lightning-consent.io" />
<!-- 2. Async queue stub. The configured Google bridge owns Consent Mode. --><script> !(function (c) { c.lightning = c.lightning || function () { (c.lightning.q = c.lightning.q || []).push(arguments); }; })(window);</script>
<!-- 3. Load the CMP async (never render-blocking). --><script async src="https://cmp.lightning-consent.io/v1/cmp.js?k=YOUR_LICENSE_KEY"></script><script> lightning("init", { bridges: { google: { tagId: "GTM-XXXXXXX" } } });</script>Use this when the CMP should load a Google tag directly. Replace the ID with
your G-… or AW-… value.
<!-- 1. Warm up the first backend round-trip. --><link rel="preconnect" href="https://cmp.lightning-consent.io" />
<!-- 2. Async queue stub. The configured Google bridge owns Consent Mode. --><script> !(function (c) { c.lightning = c.lightning || function () { (c.lightning.q = c.lightning.q || []).push(arguments); }; })(window);</script>
<!-- 3. Load the CMP async (never render-blocking). --><script async src="https://cmp.lightning-consent.io/v1/cmp.js?k=YOUR_LICENSE_KEY"></script><script> lightning("init", { bridges: { google: { tagId: "G-XXXXXXX" } } });</script>Use the generic init when another system already owns your Google setup or your site has no Google tags. Add supported vendor bridges separately.
<!-- 1. Warm up the first backend round-trip. --><link rel="preconnect" href="https://cmp.lightning-consent.io" />
<!-- 2. Consent Mode v2 default + async queue stub. MUST be first. --><script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("consent", "default", { ad_storage: "denied", analytics_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", wait_for_update: 500, }); !(function (c) { c.lightning = c.lightning || function () { (c.lightning.q = c.lightning.q || []).push(arguments); }; })(window);</script>
<!-- 3. Load the CMP async (never render-blocking). --><script async src="https://cmp.lightning-consent.io/v1/cmp.js?k=YOUR_LICENSE_KEY"></script><script> lightning("init", { theme: "light" });</script>-
Paste your selected snippet at the very top of
<head>, before any site-hosted Google tag or other tracker. ReplaceYOUR_LICENSE_KEYand the example tag ID with your values. Bridge tabs omit the inline default because the bridge owns it. -
Load the page and open its console. Run:
LightningCMP.debug();You’ll see the resolved regulation, the Consent Mode signals, and a table of any scripts the CMP is gating. If that prints, you’re installed.
That’s a complete, compliant install for the path you selected. The banner shows (or doesn’t) according to the visitor’s region, resolved at the edge.
What each part does
Section titled “What each part does”A one-line tour — the line-by-line explainer goes deeper.
| Part | Why it’s there |
|---|---|
preconnect |
Warms the TLS connection to the edge so the first config round-trip is fast. Pure performance. |
gtag('consent','default', …) |
The Consent Mode default for site-hosted Google tags. Bridge installs omit it because the Google bridge pushes the default before it loads its tag. |
The lightning() queue stub |
Lets you load cmp.js async and still call lightning('init', …) immediately — calls are queued and replayed on load. |
cmp.js?k=… |
The SDK (~12 KB gzipped), async, never render-blocking. The ?k= key authorises backend calls and carries your siteId. |
lightning('init', { … }) |
Boots the banner with your config. |
lightning(...) vs LightningCMP.*
Section titled “lightning(...) vs LightningCMP.*”Two ways to call the CMP, for two moments:
-
lightning('method', args)— the queue-safe dispatcher. Use it in the initial page markup (likelightning('init', …)above), before the SDK has finished loading. -
window.LightningCMP.*— the real API, available once loaded. Call it from event handlers and app code, e.g. a footer “Cookie settings” link:<button onclick="LightningCMP.openPreferences()">Cookie settings</button>
Next steps
Section titled “Next steps”- Choose your setup — revisit the decision if your tag stack changes.
- Configurator — generate a setup for your site and vendor mix.
- How it works — the model behind the snippet.
- Framework recipes — the same snippet for WordPress, React, Next.js, Shopify and more.
- Built-in bridges — wire Google, HubSpot, Adobe and Pardot to consent.
- Appearance & theming — make the banner yours.