Skip to content

Commit df41b26

Browse files
committed
Reworked cookie consent documentation
1 parent ce0484e commit df41b26

File tree

4 files changed

+86
-38
lines changed

4 files changed

+86
-38
lines changed

docs/setup/changing-the-language.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ extra:
127127
used as defined. Otherwise the domain part of the [`site_url`][site_url] as
128128
set in `mkdocs.yml` is prepended to the link.
129129

130-
The following properties must be set for each alternate language:
130+
The following properties are available for each alternate language:
131131

132132
`name`{ #language-name }
133133

docs/setup/ensuring-data-privacy.md

Lines changed: 83 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ automatically downloaded for [self-hosting].
2222
:octicons-milestone-24: Default: _none_
2323

2424
Material for MkDocs ships a native and extensible cookie consent form which
25-
asks the user for his consent prior to sending any data via analytics. Add the
25+
asks the user for consent prior to sending any data via analytics. Add the
2626
following to `mkdocs.yml`:
2727

2828
``` yaml
@@ -39,61 +39,109 @@ extra:
3939
1. You can add arbitrary HTML tags in the `description`, e.g. to link to your
4040
terms of service or other parts of the site.
4141

42-
Note that both, `title` and `description`, are required. If Google Analytics
43-
was configured via `mkdocs.yml`, the cookie consent will automatically include
44-
a setting for the user to disable it. Furthermore, [custom cookies] can be
45-
integrated by using the `cookies` field:
42+
The following properties are available:
4643

47-
=== "Custom cookie name"
44+
`title`{ #consent-title }
4845

49-
``` yaml
50-
extra:
51-
consent:
52-
cookies:
53-
analytics: Custom name # (1)!
54-
```
46+
: :octicons-milestone-24: Default: _none_ · :octicons-alert-24: Required –
47+
This property sets the title of the cookie consent, which is rendered at the
48+
top of the form and must be set to a non-empty string.
5549

56-
1. The default name of the `analytics` cookie is `Google Analytics`.
50+
`description`{ #consent-description }
5751

58-
=== "Custom initial state"
52+
: :octicons-milestone-24: Default: _none_ · :octicons-alert-24: Required –
53+
This property sets the description of the cookie consent, is rendered below
54+
the title, and may include raw HTML (e.g. a links to the terms of service).
5955

60-
``` yaml
61-
extra:
62-
consent:
63-
cookies:
64-
analytics:
65-
name: Google Analytics
66-
checked: false
67-
```
56+
`cookies`{ #consent-cookies }
57+
58+
: [:octicons-tag-24: insiders-4.5.1][Insiders] · :octicons-milestone-24:
59+
Default: _none_ – This property allows to add custom cookies or change the
60+
initial `checked` state and name of the `analytics` cookie. Each cookie must
61+
receive a unique identifier which is used as a key in the `cookies` map, and
62+
can be either set to a string, or to a map defining `name` and `checked`
63+
state:
64+
65+
=== "Custom cookie name"
66+
67+
``` yaml
68+
extra:
69+
consent:
70+
cookies:
71+
analytics: Custom name
72+
```
73+
74+
=== "Custom initial state"
75+
76+
``` yaml
77+
extra:
78+
consent:
79+
cookies:
80+
analytics:
81+
name: Google Analytics
82+
checked: false
83+
```
84+
85+
=== "Custom cookie"
6886

69-
=== "Custom cookie"
87+
``` yaml
88+
extra:
89+
consent:
90+
cookies:
91+
analytics: Google Analytics # (1)!
92+
custom: Custom cookie
93+
```
94+
95+
1. If you define a custom cookie as part of the `cookies` property,
96+
the `analytics` cookie must be added back explicitly, or analytics
97+
won't be triggered.
98+
99+
100+
If Google Analytics was configured via `mkdocs.yml`, the cookie consent will automatically include a setting for the user to disable it. [Custom cookies]
101+
can be used from JavaScript.
102+
103+
`actions`{ #consent-actions }
104+
105+
: [:octicons-tag-24: insiders-4.17.1][Insiders] · :octicons-milestone-24:
106+
Default: `[accept, manage]` – This property defines which buttons are shown
107+
and in which order, e.g. to allow the user to accept and manage cookie
108+
settings:
70109

71110
``` yaml
72111
extra:
73112
consent:
74-
cookies:
75-
analytics: Google Analytics # (1)!
76-
custom: Custom cookie
113+
actions:
114+
- accept
115+
- manage
77116
```
78117

79-
1. If you add a custom cookie to the `cookies` field, the `analytics`
80-
cookie must be added back explicitly, or analytics won't be triggered.
118+
The cookie consent form includes three types of buttons:
119+
120+
- `accept` – Button to accept selected cookies
121+
- `reject` – Button to reject all cookies
122+
- `manage` – Button to manage settings
81123

82124
When a user first visits your site, a cookie consent form is rendered:
83125

84126
[![cookie consent enabled]][cookie consent enabled]
85127

128+
[Insiders]: ../insiders/index.md
129+
[Custom cookies]: #custom-cookies
130+
[cookie consent enabled]: ../assets/screenshots/consent.png
131+
132+
#### Change cookie settings
133+
86134
In order to comply with GDPR, users must be able to change their cookie settings
87-
at any time. This can be done by creating a simple link as part of any document,
88-
e.g. your privacy policy:
135+
at any time. This can be done by adding a simple link to your [copyright notice]
136+
in `mkdocs.yml`:
89137

90-
``` markdown
91-
[Change cookie settings](#__consent){ .md-button }
138+
``` yaml
139+
copyright: >
140+
Copyright © 2016 - 2022 Martin Donath –
141+
<a href="#__consent">Change cookie settings</a>
92142
```
93143

94-
[Insiders]: ../insiders/index.md
95-
[custom cookies]: #custom-cookies
96-
[cookie consent enabled]: ../assets/screenshots/consent.png
144+
[copyright notice]: setting-up-the-footer.md#copyright-notice
97145

98146
### Built-in privacy plugin
99147

docs/setup/setting-up-site-analytics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ integrated with the [cookie consent] feature[^1].
167167

168168
[![feedback report]][feedback report]
169169

170-
The following properties must be set for each rating:
170+
The following properties are available for each rating:
171171

172172
`icon`{ #feedback-rating-icon }
173173

docs/setup/setting-up-the-footer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extra:
4040
</div>
4141
</div>
4242
43-
The following properties must be set for each link:
43+
The following properties are available for each link:
4444
4545
`icon`{ #social-icon }
4646

0 commit comments

Comments
 (0)