Skip to content

Visitor data and consent in Web Analytics: what is kept, and when

Describes Web Analytics 0.9.0.

Web Analytics sets no cookie and, as it ships, stores no IP address and no raw User-Agent. Two sections of its Settings page let you keep more about visitors, and decide whether a visitor has to agree first. What a site may keep, and whether it must ask, depends on the law it answers to: that decision is yours.

Where to find it

Web Analytics → Settings (/admin/web-analytics/settings), sections Who a visitor is and When it is collected. You need the Owner role or the Web Analytics permission. Changes take effect after Save settings at the bottom of the form.

Who a visitor is

By default a visitor is a one-way hash of the address and the browser that changes every day. Each setting below keeps more. They are all off until you switch them on.

  • A visitor ID lasts: One day (the default), One week, One month, or Until the address or browser changes. After that the same person counts as a new visitor. A longer period recognises a returning visitor across days. Changing it splits today’s open visits. The Visitors number on the reports still counts daily unique visitors whatever you pick.
  • IP address: Not kept, Its network only (the first three parts of an IPv4 address, or the first 48 bits of an IPv6 one), or The whole address.
  • Keep the browser’s full User-Agent: the whole string the browser sent, such as which crawler or library and which version.
  • Keep request headers: the headers of a visit’s first page view, in arrival order. Cookies, authorisation and anything named like a token or key are never kept; headers carrying the visitor’s address only when the whole address is.
  • Keep the network’s owner: the network’s number and name, and whether it is a hosting provider, when the site’s geo resolver returns them.
  • Keep device measurements: what the client script measures about the device (screen, time zone, languages, processor, graphics card, fonts, canvas and sound rendering) and a hash of them that stays the same when the address changes. This is browser fingerprinting. It needs the client script on.

All of this is kept once per visitor, when a visit starts, and shown on the visit’s page and on the Bots page. It is removed when the visitor hasn’t been seen for as long as raw events are kept. Switching a setting off stops new data; to remove what is stored now, use Remove stored profile data under Stored data.

When it is collected

Each kind of collection has its own rule:

  • Counting visits: page views, visits and what visitors do, under the visitor ID.
  • Details about a visitor: whatever Who a visitor is keeps (address, User-Agent, headers, network).
  • Device measurements: the client script’s measurements and their hash.
  • Session recordings: pointer movement, clicks and scrolling.

and each rule is one of:

  • Always — visitors are told, not asked: the default, and how the module has always worked.
  • Only after the visitor agrees.
  • Until the visitor objects: collected unless the visitor said no. A browser that sends Global Privacy Control or Do Not Track counts as an objection.

Start from: fills the four rules with a ready-made combination: Tell, don’t ask, Count visits, ask for the rest, Ask first or Collect until refused. It only fills the menus, and says Not saved yet. until you save.

Details, device measurements and recordings describe a visitor, so they are only kept for one whose visits are counted.

  • Without an answer that allows it: what happens to a page view that may not be counted. Nothing is recorded, or The page view is counted, with no visitor. The second keeps page totals whole, but every such view is a visitor and a visit of its own, so those two numbers rise with it.
  • Asked under: the consent banner’s category these rules follow: Analytics, Marketing or Preferences.

A line under these says where answers come from: the Legal module’s cookie banner, the site’s own consent tool, or Nothing on this site asks visitors: no visitor has given an answer. If a rule waits for a yes and nothing asks, a warning says it will never be collected.

If device measurements are kept without Only after the visitor agrees, a warning explains that EU and UK regulators treat browser fingerprinting as needing consent.

What it doesn’t do

  • It doesn’t decide for you what the law allows.
  • Nothing collected before a visitor says yes is kept for later.
  • Query strings are never stored, apart from campaign (utm_) parameters and an ad platform’s click identifier.
  • Respect Do Not Track (under Collection) is separate: while it is on, a browser sending DNT or Global Privacy Control is not tracked under any rule, even after a yes in the banner.

For developers

Answers come from the Legal module’s cookie banner when it is installed and on. A site with its own consent tool sets config :phoenix_kit_web_analytics, consent_source: {MyApp.Consent, :status}, returning :granted, :denied or :unknown; a source that fails counts as :denied. The tracking plug must run after :fetch_session, and a consent change must be followed by a full page reload.