DEPRECATED

This component has been deprecated.

  • Molecule
  • CORE COMPONENT
  • Taxonomic name: M-COOKIE-POLICY
  • Added on: v3.0.0 (15/09/17)
  • Updated on: v5.10.0 (10/08/21)

Cookie policy

For displaying that cookies are required for providing the best possible online experience.


Design and usage

  • Customisable cookie message, which includes a link to the full cookie policy.
  • Default 13 month expiry for acceptance cookie, which can be modified to a different number of months if required.

Structure

  • Suggested wording for the cookie policy is:

    We use cookies to enhance your browsing experience, analyze site traffic, offer you personalised content and to help us make this website better. By accepting or continuing to browse our site, you agree to our use of cookies. See our cookie policy for more information and how to manage them.

  • It is recommended you consult with legal if you wish to propose alternative wording for the cookie policy.
  • Cookie policy can either be at the top of the page or fixed to the bottom of the viewport. It is always visible on the page and any subsequent reloads, unless the user dismisses it by using the accept button.
  • Cookie policy wording is aligned left to the page.
  • Accept button is aligned to the right of the page except on mobile where it stacks beneath the copy.
  • When the cookie message is fixed to the bottom of the viewport, if it becomes taller than the viewport then the message must be scrollable so that the entire message can be read and then dismissed.
  • Character limit of 600.

Label

  • An accept button will always accompany the cookie policy text.
  • A link to be able to view or manage privacy policy / cookie policy should be present within the text.

Accessibility and screen readers

  • The cookie policy component must always be placed at the top of the page, even if being displayed at the bottom of the viewport, so that all users are informed of the use of cookies as soon as they visit a page.
  • Inclusion of a hidden H2 to aid in understanding of the component whilst using assistive technologies. Although these heading does not follow the correct nesting order, it does not constitute a failure of WCAG 1.3.1 as specified within WCAG technique H42 - example 2. This component is an exception to maintaining the heading order as removal of the heading detrement any assistive technology users.

Non-js requriements and considerations

  • If a team opts to place their cookie policy at the bottom of the viewport, in a non JS scenario, the cookie policy must default to the top of the page.

Placement

  • Can be placed either at the top of the page or fixed to the bottom of the viewport.

Design Anatomy

  • Cookie policy copy is aligned left to the grid.
  • Accept button is aligned to the right of the grid except on mobile where it stacks beneath the copy.
  • Content has 20px top and 20px bottom padding.
  • Mobile has 20px margin between its copy and CTA
  • Body copy should be 16pt #FFF regular.
  • Background colour #004FB6

Examples

Interactive examples

Breadcrumb anchored to bottom of screen

Note: the "cookie_decision" cookie must not be set for standards.abeille-assurances.fr to be able to see the cookie message.

Code example

<div class="l-whole-page">
	<div class="m-cookie-policy [ Modifers ] t-accent-dark" data-module="m-cookie-policy" data-module-load="true" data-cookie_expires="..." data-cookie-name="...">
		<div class="m-cookie-policy__content">
			<h2 class="u-hidden--visually">Cookie policy</h2>
			<p>...</p>
			<a href="..." class="m-cookie-policy__close">...</a>
		</div>
	</div>
	<!-- Masthead -->
	...
</div>

Development and test

Notes for developers

Ensure a hidden H2 is included at the top of the cookie policy message to improve accessibility by providing better context for the message and also to make it more discoverable by screen reader users.

Ensure that the close link contains understandable hidden text so that it it clear to the users that they are accepting cookies and closing the cookie message.

The default name for the cookie is cookie_decision but this can be changed as required by setting the data attribute data-cookie-name to the required value. If a custom name is used ensure that the serverside implementation matched and the setting is also set for the the accessibilty settings component.

Server-side implementation

There must be a server-side implementation to set a cookie so that the cookie message does not display for X number of months (by default this would be 13 months). When a user accepts the cookie the server-side solution must not take the user away from the page they were on. The JavaScript will hide the cookie policy message if one is found and the cookie has been set but due to the time it takes for assets to load users will momentarily see the message before the JavaScript removes it, please ensure that the message is removed server-side if the cookie had been set.

To match with the cookie set by the JavaScript ensure that the cookie is set with the following values:

Cookie name
cookie_decision
Value
True
Path
/

By default the JavaScript will set the cookie expiration date to 13 months. This can be changed by specifying the number of months in the data-cookie_expires attribute.

Controling cookie policy programatically

Cookie policy can now be closed programatically. The following method is available for use:

Method Description
close() Close the cookie policy.

For example:

document.addEventListener( 'frameworkready', function () {
	FRAMEWORK.require([ 'blocks/m-cookie-policy' ], function ( mCookiePolicyModule ) {
		var mCookiePolicyEl = document.querySelector( '#cookiePolicyId' ),
			mCookiePolicyInstance = mCookiePolicyModule.initInstance( mCookiePolicyEl );		mCookiePolicyInstance.close();
	});
});

Changing locale settings

The JavaScript includes an alert for assistive technologies to highlight the cookie settings have been saved on closure of the cookie policy message. Please ensure the alert 'The cookie setting has been successfully saved' is translated in your locale.js file.

en: {
	mCookiePolicy : {
		successfullySaved : 'The cookie setting has been successfully saved.',
		failed : 'Cookies are not enabled so your preference could not be saved.',
	},
},

For more information on this, see our page on how to change locale settings within JavaScript.


Notes for testers

  • The cookie policy message must clearly contain a link to the full cookie policy.
  • When JavaScript is available and the user chooses to close the cookie policy. If cookies are enabled a cookie will be set with the expiry set to the chosen number of months, the cookie policy removed from the page without a page refresh and the closure of the cookie message announced to screen reader users.
  • When JavaScript is not available and the user chooses to close the cookie policy the page should reload and should no longer contain the cookie policy message. A cookie must have been set with the expiry set to the chosen number of months.

Classes overview

The following table gives you a quick overview of the CSS classes that can be applied.

Class Outcome Required Applied to Comments
.m-cookie-policy Base style cookie policy Yes div.t-accent-dark  
.m-cookie-policy--sticky Modifer to stick the cookie policy message to the bottom of the screen   .m-cookie-policy  
.m-cookie-policy__content Base styling for content area of cookie policy Yes .m-cookie-policy > div  
.m-cookie-policy__close Base style accept and close link Yes .m-cookie-policy__content > a:last-child  

Keyboard operations

TAB

Tabbing to a link should make the link clearly visually different so that the focus point on the page is obvious to the user.

Enter

When JavaScript is available hitting enter on the accept and close link should cause a cookie to be set and the cookie policy to be closed without a page refresh.

Component releases

  • Added on: v3.0.0 (15/09/17)
  • Updated on: v5.10.0 (10/08/21)

Latest update:

  • updated: Cookie policy can now be closed programatically.
  • deprecated: Following legal changes surounding the use of cookies on websites, this component has been deprecated and replaced by a more comprehensive third party solution.

Full version history

A full history of changes and enhancements detailing all minor and major updates to the component.

View full version history

Want something new in Framework, or to chat about an issue you're having with it?

Contact the team