Cookie consent banner: ask visitors and keep a record
Describes Legal 0.7.0.
The Legal module can show visitors a cookie consent banner, remember what each visitor agreed to, and keep a log of those decisions. The same page lists what the site’s modules collect, which is what the banner and the Cookie Policy tell visitors about.
Where to find it
Open Settings, then Legal (/admin/settings/legal), and scroll to Cookie Consent Widget and What this site collects. You need a role with the Legal permission, and the Legal and Publishing modules must be on. The legal pages themselves have a guide of their own.
Turning the banner on
Enable Cookie Banner switches the banner on or off for visitors, and is saved at once. The rest of the settings appear only while it is on.
The banner links to your Cookie Policy and Privacy Policy, so both should be published. If either isn’t, the card warns Legal pages not published and names the missing ones.
Banner settings
Choose a Consent Mode:
- Strict: “Full GDPR compliance: floating icon, script blocking, re-consent on policy updates”.
- Notice: “Simple notice: banner shown once, no blocking, no floating icon”.
In Strict mode, a note says whether the floating cookie icon will show. It shows only when you ticked a framework that asks visitors to opt in: GDPR, UK GDPR, LGPD or PIPEDA. Icon Position puts it in a corner of the screen: Top Left, Top Right, Bottom Left or Bottom Right. Visitors use the icon to change their choice later.
In Notice mode, Hide for authenticated users keeps the banner away from signed-in users (“they agreed via Terms”).
Policy Version is read only. It is worked out from when the Cookie Policy and Privacy Policy were last updated.
Google Consent Mode v2 passes the visitor’s choices to Google Analytics and Google Ads tags.
Record of decisions
Each decision a visitor makes is sent to the server, which stores it in a signed cookie that the site’s own data collection obeys. These settings decide what else is kept:
- Keep a log of each decision: what was agreed to and refused, when, and under which policy version.
- Keep the visitor’s IP address with it: off by default, so the log shows that a decision was made without saying who made it.
- Keep a hash of the browser’s User-Agent with it.
- Reload the page when a visitor takes a consent back: a script that already ran can’t be stopped, so a reload shows the page under the new choice.
- Ask again after (days): how long a decision lasts before the banner asks again, from 1 to 730 days. Any other number is refused and nothing is saved.
Press Save Settings to keep the changes in this card.
Preview
Below the settings, Preview shows the banner as visitors see it, with Customize, Reject and Accept All, and the floating icon when it will show. On the live site, Customize opens Privacy Preferences with a switch per category: Essential (always on), Analytics, Marketing and Preferences, then Reject All or Save Preferences.
What this site collects
This list is written by the site’s modules, not by hand: each module that collects something declares what it is. Each entry shows its category, how it is collected (Collected without asking, Only after the visitor agrees, Until the visitor objects or Not collected), the data involved and how long it is kept.
Ticked entries are named in the banner and in the generated Cookie Policy. Untick one to leave it out of both. Warnings appear under an entry when:
- it is collected but you unticked it: “This is being collected, but visitors are not told about it.”
- it waits for consent while the banner is off: “This waits for consent, but the banner is off, so nothing is collected.”
When the list changes after the Cookie Policy was generated, a warning asks you to generate the policy again.
If nothing on the site declares collection, the card says “No enabled module declares that it collects anything.”
What it doesn’t do
- There is no admin page for reading the consent log. The decisions are stored, but this module shows them nowhere in the admin.
- How each kind of data is collected is set in the module that collects it, not here.
For developers
The banner needs its script and styles in your app. Run mix phoenix_kit_legal.install and follow the steps it prints; the module’s README describes them.