Cookie Consent Script

Dokumentation

Installation

Include cookiescript.js on your page like so:

<!-- Minified Cookie Script served from our CDN -->
<script src="//cdn.cookiescript.info/libs/cookiescript.min.js"></script>

Customization

To customize the Cookie Script plugin, you can provide an options object before including it.

<script>
    window.cookieconsent_options = {
        learnMore: 'More info',
        link: 'http://example.com/cookiepolicy'
    };
</script>
<script src="//cdn.cookiescript.info/libs/cookiescript.min.js"></script>

On the fly

You can customize Cookie Script options on the fly (once it is loaded) by calling:

window.update_cookieconsent_options({
    learnMore: 'Learn more'
});

Options

These are the options you can pass to Cookie Script.

message (string)

Default: ‘This website uses cookies to ensure you get the best experience on our website’

The message shown by the plugin.

dismiss (string)

Default: ‘Got it!’

The text used on the dismiss button.

learnMore (string)

Default: ‘More info’

The text shown on the link to the cookie policy (requires the link option to also be set)

link (string)

Default: null

The url of your cookie policy. If it’s set to null, the link is hidden.

container (string: CSS selector)

Default: null

The element you want the Cookie Script notification to be appended to. If null, the Cookie Script plugin is appended to the body.

Note: the majority of our built in themes are designed around the plugin being a child of the body.

theme (string)

Default: ‘light-floating’

The theme you wish to use. Can be any of the themes from the style directory, e.g. dark-top.

If you wish to use your own CSS instead, specify the URL of your CSS file. e.g. styles/my_custom_theme.css. This can be a relative or absolute URL.

To stop Cookie Script from loading CSS at all, specify false.

path (string)

Default: ‘/’

The path for the consent cookie that Cookie Script uses, to remember that users have consented to cookies. Use to limit consent to a specific path within your website.

domain (string)

Default: The current subdomain

The domain for the consent cookie that Cookie Script uses, to remember that users have consented to cookies. Useful if your website uses multiple subdomains, e.g. if your script is hosted at www.example.com you might override this to example.com, thereby allowing the same consent cookie to be read by subdomains like foo.example.com.

expiryDays (integer)

Default: 365

The number of days Cookie Script should store the user’s consent information for.

target (string)

Default: _self

The target of the link to your cookie policy. Use to open a link in a new window, or specific frame, if you wish.






English ▼