Complete API Reference
Cookie Categories
The following levels are available in TermsFeed Cookie Consent solution. Tag your JavaScript using any of the following levels.
-
strictly-necessaryfor essential scripts.For example, account login related cookies. Strictly necessary cookies are loaded automatically and cannot be disabled by the user.
<script type="text/plain" data-cookie-consent="strictly-necessary"></script> -
functionalityfor enhanced features scripts.For example, remember users language preferences or remembering various choices.
<script type="text/plain" data-cookie-consent="functionality"></script> -
trackingfor analytics and performance vendor scripts.For example, analytics such as Google Analytics.
<script type="text/plain" data-cookie-consent="tracking"></script> -
targetingfor marketing and advertising vendor scripts.For example, Google AdSense/AdWords remarketing.
<script type="text/plain" data-cookie-consent="targeting"></script>
Methods
cookieconsent.run(config)
Initializes the TermsFeed Cookie Consent banner with the provided configuration.
cookieconsent.run({
"consent_type": "express",
"website_name": "My Website",
// ... other options
});
cookieconsent.openPreferencesCenter()
Opens the Preferences Center modal for users to change their consent.
// Example usage:
document.getElementById('settingsButton').addEventListener('click', function() {
cookieconsent.openPreferencesCenter();
});
Configuration options
| Parameter | Type | Default | Values | Description |
consent_type |
String | "express" |
"express", "implied" |
Type of consent |
notice_banner_type |
String | "headline" |
"simple", "headline", "interstitial", "standalone" |
Banner design |
palette |
String | "light" |
"light", "dark" |
Color scheme |
language |
String | "en" |
See i18n folder | Language code |
website_name |
String | - | Any string | Your website name |
website_privacy_policy_url |
String | - | URL | Privacy Policy link |
website_impressum_url |
String | - | URL | Impressum link (optional) |
open_preferences_center_selector |
String | "#changePreferences" |
CSS selector | Button ID |
page_load_consent_levels |
Array | - | Array of categories | Categories to load on page load |
notice_banner_purposes_levels |
Array | All categories | Array of categories | Categories to show |
preferences_center_close_button_hide |
Boolean | false |
true, false |
Hide close button |
notice_banner_reject_button_hide |
Boolean | false |
true, false |
Hide reject button |
page_refresh_confirmation_buttons |
Boolean | false |
true, false |
Refresh after consent |
cookie_domain |
String | - | Domain string | For cross-domain consent |
cookie_secure |
Boolean | false |
true, false |
Require HTTPS |
user_consent_token |
String | - | Any string | Custom consent token |
callbacks |
Object | - | Object | Event callbacks |
callbacks_force |
Boolean | false |
true, false |
Fire callbacks always |
demo |
Boolean | false |
true, false |
Demo mode (no cookies) |
debug |
Boolean | false |
true, false |
Debug logging |
Callbacks
| Callback | Parameters | When Fired |
notice_banner_loaded |
None | Banner displays |
i_agree_button_clicked |
None | User clicks "I Agree" |
i_decline_button_clicked |
None | User clicks "I Decline" |
change_my_preferences_button_clicked |
None | User opens preferences |
scripts_specific_loaded |
level (String) |
Category scripts load |
user_consent_saved |
None | Consent saved to cookie |
CSS Classes References
Banner CSS Classes
/ Main banner container /
.termsfeed-com---nb { }
/ Banner title /
.termsfeed-com---nb .cc-nb-title { }
/ Banner text content /
.termsfeed-com---nb .cc-nb-text { }
/ Button container /
.termsfeed-com---nb .cc-nb-buttons { }
/ Accept button /
.termsfeed-com---nb .cc-nb-okagree { }
/ Reject button /
.termsfeed-com---nb .cc-nb-reject { }
/ Preferences button /
.termsfeed-com---nb .cc-nb-changep { }
Preferences Center CSS Classes
/ Overlay /
.termsfeed-com---pc-overlay { }
/ Dialog container /
.termsfeed-com---pc-dialog { }
/ Tab navigation /
.termsfeed-com---pc .cc-pc-head-tab { }
/ Active tab /
.termsfeed-com---pc .cc-pc-head-tab-link.cc-active { }
/ Tab content /
.termsfeed-com---pc .cc-pc-content { }
/ Category toggle /
.termsfeed-com---pc .cc-pc-category-toggle { }