Documentation

Quick start and concepts.

This page contains the most important snippets for embedding SimpleCMP. The full API reference lives in the repository under docs/ — the implementation is in the pre-1.0 phase and is still changing.

Installation

Two approaches: as an npm package for build pipelines, or as an IIFE script tag for static sites and drop-in scenarios.

npm package

# with pnpm
pnpm add simplecmp

# or with npm
npm install simplecmp

IIFE drop-in (self-hosted)

For privacy reasons, we do not deliver SimpleCMP via public CDNs. Place the bundle in your own assets/ directory — see Installation on a static site for the complete guide.

<link rel="stylesheet" href="/assets/vendor/simplecmp/default.css">
<script src="/assets/vendor/simplecmp/simplecmp.global.js"></script>
<script>
  SimpleCMP.init({ /* config */ });
</script>

Quick start

Minimal configuration with two services. Privacy policy and legal notice links are separate — important for the German market (TMG/MStV).

import { init } from 'simplecmp';

init({
  storageName: 'simplecmp-myapp',
  privacyPolicy: 'https://example.com/datenschutz',
  imprint:       'https://example.com/impressum',
  floatingTrigger: { label: 'Cookie-Einstellungen' },
  services: [
    {
      name: 'analytics',
      title: 'Google Analytics',
      purposes: ['analytics'],
      cookies: [/^_ga/, '_gid'],
      required: false,
      default:  false
    },
    {
      name: 'matomo',
      title: 'Matomo',
      purposes: ['analytics'],
      cookies: ['_pk_id', '_pk_ses'],
      required: false,
      default:  false
    }
  ]
});

Headless mode

Do you just need the state machine, no banner? The engine subpath skips the Lit components and is significantly smaller.

import { getManager, addEventListener } from 'simplecmp/engine';

const manager = getManager({
  storageName: 'simplecmp-spa',
  services: [/* ... */]
});

addEventListener('saveConsents', (consents) => {
  console.log('Consent-State:', consents);
  // update your own UI here
});

// From your own banner:
manager.updateConsent('analytics', true);
manager.saveConsents();

Enable recorder

In the dev or staging build, enable the recorder before the first init() call. Note: do not use it in production without a sampling rate.

import { init } from 'simplecmp';
import { startRecorder } from 'simplecmp/recorder';

startRecorder({
  serviceDB: 'https://library.simplecmp.eu',
  onUnknown: (item) => console.warn('Unknown:', item),
  onKnown:   (item, service) => console.log('Found:', service.name)
});

init({ services: [] });

// After a few minutes of clicking:
recorder.exportConfig();
// → { services: [ { name: 'ga', cookies: [...] }, ... ] }

// In CI:
recorder.assertNoUnknown(); // throws on unknown items

Configure CMS bridge

For production use: SimpleCMP posts to your webhook for every unknown detection. A sampling rate prevents webhook floods with high traffic.

import { init } from 'simplecmp';

init({
  services: [/* ... */],
  bridge: {
    url:        'https://example.com/api/simplecmp/webhook',
    secret:     window.SCMP_PUBLIC_NONCE,   // nonce, not secret
    sampleRate: 0.05,                       // 5% of visitors
    dedupTTL:   3600                        // seconds
  }
});

Webhook schema v2 is documented in docs/cms-bridge-webhook.md. A Node.js receiver is located at demos/cms-bridge-receiver.mjs.


Integrate WordPress without a plugin

The WordPress plugin is available as a beta. If you want to work without a plugin, integrate SimpleCMP manually into each WordPress theme. In functions.php:

function mytheme_enqueue_simplecmp() {
  // Bundle beforehand via `composer require` or manually
  // copy to wp-content/themes/<theme>/assets/vendor/simplecmp/.
  wp_enqueue_style(
    'simplecmp',
    get_template_directory_uri() . '/assets/vendor/simplecmp/default.css'
  );
  wp_enqueue_script(
    'simplecmp',
    get_template_directory_uri() . '/assets/vendor/simplecmp/simplecmp.global.js',
    array(), null, false
  );

  $config = array(
    'storageName' => 'simplecmp-' . sanitize_title(get_bloginfo('name')),
    'privacyPolicy' => get_permalink(get_option('wp_page_for_privacy_policy')),
    'imprint' => get_permalink(get_page_by_path('impressum')),
    'services' => apply_filters('simplecmp_services', array())
  );

  wp_add_inline_script(
    'simplecmp',
    'SimpleCMP.init(' . wp_json_encode($config) . ');'
  );
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_simplecmp');

Browser consent signals

SimpleCMP respects the Global Privacy Control signal (Sec-GPC: 1) and the legacy DNT header. The default behavior is auto-decline; it can be changed via configuration.

init({
  consentSignals: {
    gpc: 'auto-decline',     // or 'hide-banner' | 'confirm'
    dnt: 'ignore'            // DNT is de facto deprecated
  },
  services: [/* ... */]
});

More docs

The full documentation and all ADRs (Architectural Decision Records) are in the GitHub repository:

Need help?

Integration support directly from the maintainers.

At WapplerSystems, we use SimpleCMP every day in client projects. If you need support with rollout, theming, or a custom extension — we're happy to help.