Connect TermsFeed Privacy Consent to your own code through its callbacks, its Privacy Preferences Center method, and the record it stores in the browser. Consent state is not available synchronously at page load, so plan your timing with the load sequence.

Load sequence of the Privacy Consent script, from plugin.js to the point where Privacy Consent starts

The public API calls your code uses

Build on these calls and on the localStorage key termsfeed_privacy_consent_state. Every other global Privacy Consent sets is internal. Look up each one with its arguments in the JavaScript API reference.

Call When to use it
window.termsfeed_privacy_consent_callbacks = callbacks Install your callbacks before the script has loaded
window.termsfeed_privacy_consent.v1.callbacks(callbacks) Install your callbacks after the script has loaded
window.termsfeed_privacy_consent.v1.openPrivacyPreferences() Open the Privacy Preferences Center from your code
window.termsfeed_privacy_consent.v1.visitor Read the location and consent model of the visit inside an initialized callback

How the script works

Page What you learn
SDK Load Sequence The request order and consent timing
Callbacks and Consent Semantics Which callback runs and what it reports

Guides for your own code

Page What you build
Run Code on Consent Code that runs on every allowed page view, and code that reacts to each accept and withdrawal
Read Consent State A reader function for each vendor category and vendor
Single-Page Applications Route changes and late embeds
Server-Side Tracking A consent value your backend checks
Cross-Subdomain Consent A shared cookie, or a question on each origin

Reference pages

Page What it lists
JavaScript API Reference Globals, methods, callbacks, attributes, and custom elements
DOM and CSS Selectors IDs, classes, data attributes, and CSS custom properties
Content Security Policy The allowances the script needs
Versions and Changelog What a settings change or a script update does
Console Error Reference Every console code and its cause
Trigger Actions Every vendor tag type, trigger action, and slot
Stored on the Device Every field of the stored record
Settings Reference Consent banner settings
Category Mapping The consent signal each vendor category sets
Concepts and Vocabulary The terms these pages use

Read the console during development

Keep the Console tab open while you build. Privacy Consent prints errors with [ee] and warnings with [ww] on every page where they occur, each with a code. Match each code with its cause in the console error reference.