Extended Configuration
This is an example of an extended configuration.
What is shown here
- Forcing specific language – Slovak (using
defaultLang), ie. disabling auto-detection (autodetectLang) - Setting multiple company names in the consent text (
companyNames) - Using
forceas adisplayModeinstead ofsoft(which is used in other examples) -
Overwriting raw configuration of the underlying cookie-consent component (via
configoption), to modify some advanced features. - Clearing localStorage when user gives consent to only necessary data (
onFirstConsent) - Clearing localStorage when user updates consent and rejects some consent category (
onChange) - Using
cookieTableconfiguration to list cookies in the preferences modal - Overriding default translation (
translationOverrides) for consent modal title - Etc.
See page source for details.
Use cookieConsent instance
When callbacks don't satisfy your needs for conditional code execution, you can also store cookieConsent instance in a variable and access it later when needed – see source code.
Example link with conditional logic activated onclick
(see browser console – note difference with and without accepted consent)