Skip to content

Cookie Consent

Use this class to alert users about the use of cookies on the website and comply with cookie laws. The class utilizes the Cookie Consent package by Osano to create and handle the cookie alert and functionality.

Installation

This class is preinstalled and loaded asynchronously with Genesis out of the box.

Import the CookieConsent extension class in your Global.js file.

// Global.js
import {CookieConsent} from 'extensions/cookie-consent';

Example Usage

.js

Initialize the CookieConsent class object after importing.

Preferred asynchronous initialization:

(async () => {
    const {CookieConsent} = await import('extensions/cookie-consent');

    new CookieConsent({
        content: {
            dismiss: 'Got it!',
            href: 'https://www.cookiesandyou.com/',
            link: 'Learn More',
            message: 'This website uses cookies to ensure you get the best experience on our website.'
        },
        palette: {
            button: {
                background: '#f9f9f9',
                text: '#000000'
            },
            popup: {
                background: '#222222',
                border: '#f9f9f9',
                text: '#ffffff'
            }
        }
    });
})();

Alternatively:

import {CookieConsent} from 'extensions/cookie-consent';

new CookieConsent({
    content: {
        dismiss: 'Got it!',
        href: 'https://www.cookiesandyou.com/',
        link: 'Learn More',
        message: 'This website uses cookies to ensure you get the best experience on our website.'
    },
    palette: {
        button: {
            background: '#f9f9f9',
            text: '#000000'
        },
        popup: {
            background: '#222222',
            border: '#f9f9f9',
            text: '#ffffff'
        }
    }
});

Options

The CookieConsent class takes a required Cookie Consent options object for the first parameter. These options control the look and behavior of the cookie consent alert.