Documentation
Up and running in 5 minutes
You get the snippet after creating a property, under Property → Integration. It looks like this:
<script src="https://consented.eu/sdk/dist/stub.js" data-block="googletagmanager.com/gtag|connect.facebook.net"></script> <script async src="https://consented.eu/p/YOUR-PROPERTY-ID/cmp.js"></script>
The first line is the stub: under 1 KB, synchronous, and it has to come before every other script. It blocks the patterns listed in data-block right away and sets the Consent Mode defaults.
Declarative — for scripts you embed yourself:
<script type="text/plain" data-consented="google-analytics-4"> gtag('config', 'G-XXXXXXX'); </script>
Pattern-based — for scripts that others embed:
Add URL fragments to each service (e.g. googletagmanager.com/gtag). A MutationObserver strips the src attribute before the browser loads the file, and puts it back once consent is given.
// Wait until the state is known Consented.ready(function (state) { if (state && state.services['google-analytics-4']) { startTracking(); } }); // React to changes Consented.on('change', function (state) { console.log(state); }); // Open the detail view — or just put data-consented-open on the element Consented.openSettings(); // Proof of consent Consented.getConsentId();
| Event | When |
|---|---|
consented_ready | Runtime loaded, state known |
consented_update | After every decision the visitor makes |
Every consent gets an ID that is shown to the visitor in the detail view. With it they can request access or deletion without an account:
GET /api/v1/consent/{consentId}
DELETE /api/v1/consent/{consentId}
Or more conveniently via the public lookup page.