Connect the cookie banner to your own code
Connect TermsFeed Privacy Consent to your own code through its callbacks, its Preferences Center method, and the record it stores in the browser. Every integration in this manual uses that surface. Consent state is not available synchronously at page load, so plan your timing with the load sequence.
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 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
Start with these pages, which set the timing and meaning of every answer your code receives.
| Page | What you learn |
|---|---|
| How the TermsFeed Privacy Consent SDK Loads and Runs | The request order and consent timing |
| TermsFeed Privacy Consent Callbacks and Consent Semantics | Which callback runs and what it reports |
Guides for your own code
Follow these guides to connect an answer to code that Privacy Consent does not run for you.
| Page | What you build |
|---|---|
| Run Code on Accept or Decline | Code that runs on every allowed page view, and code that reacts to each accept and withdrawal |
| Read TermsFeed Privacy Consent State in Your Own Code | A reader function for each vendor category and vendor |
| Fire Tags When Visitors Consent | Google Tag Manager tags that fire with no page reload |
| Use TermsFeed Privacy Consent in a Single-Page Application | Route changes and late embeds |
| Carry TermsFeed Privacy Consent to Server-Side Tracking | A consent value your backend checks |
| Consent Across Subdomains | A shared cookie, or a question on each origin |
Reference pages
Look up every name, setting, and code here, including the reference pages that sit in other sections for their readers.
| Page | What it lists |
|---|---|
| JavaScript API Reference | Globals, methods, callbacks, attributes, and custom elements |
| TermsFeed Privacy Consent DOM and CSS Contract | IDs, classes, data attributes, and CSS custom properties |
| Content Security Policy | The allowances the script needs |
| TermsFeed Privacy Consent Versions and What Changes Mean | What a settings change or a script update does |
| Console Error Reference | Every console code and its cause |
| The TermsFeed Privacy Consent Vendor Tag Matrix | Every vendor tag type and trigger action |
| Stored on the Device | Every field of the stored record |
| Every Setting in the TermsFeed Privacy Consent App | Consent banner settings |
| Vendor Category Mapping | The consent signal each vendor category sets |
| Words Used Throughout the TermsFeed Privacy Consent Guides | 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.