Web Analytics 0.7.0: Visitor profiles, a Bots page and consent rules
Web Analytics 0.7.0 lets a site choose, one switch at a time, what it keeps about its visitors, scores each one for how automated it looks on a new Bots page, and ties every kind of collection to the visitor’s consent.
Who a visitor is
Settings has a new Who a visitor is section. Each switch keeps one more thing, once per visitor, when a visit starts: the IP address (not kept, its network only, or the whole address), the browser’s full User-Agent, request headers, the network’s owner, and device measurements. All are off by default, and nothing is written to the event rows. Cookies, authorisation and anything named like a token or key are never kept. Profiles are removed with the raw events once the visitor hasn’t been seen for that long, and Remove stored profile data takes stored data back.
A visitor ID lasts sets how long one person counts as the same visitor: one day (the default), one week, one month, or until the address or browser changes. Daily visitor counts stay comparable whatever you pick.
A Bots page
A new Bots page under Web Analytics ranks visitors by a bot score and shows the reasons, such as Never ran JavaScript, Pages faster than a person reads or Device and User-Agent disagree. It groups them by network, subnet, address, device or User-Agent, and can list the rows with a likely bot to paste into a firewall rule. The score is evidence only: nothing is dropped or blocked because of it. Most reasons need the matching detail kept in Who a visitor is.
When it is collected
A new When it is collected section sets a rule for visits, visitor details, device measurements and recordings: always, only after the visitor agrees, or until they refuse. Answers come from the Legal module’s cookie banner or from the site’s own consent tool. A page view that may not be counted is dropped by default, or can be counted with no visitor. The module also tells the Legal module’s banner and policy what it collects.
Fixes
Reports from raw events and from daily rollups now agree under every visitor ID period, and visits spanning midnight are split by day the same way everywhere. Removing a profile also clears its address and User-Agent from stored headers.
Upgrading
Run mix phoenix_kit.update for migrations V09 and V10. Every new switch is off and every consent rule is set to always by default, so a live site collects the same as before until you change them. A visitor’s change of answer needs a full page load to take effect; the Legal module reloads on withdrawal, and a site’s own consent tool must do the same.
Full release notes: Web Analytics 0.7.0
0.7.0 · 13 October 2026
Requires mix phoenix_kit.update (migrations V09 and V10).
Added
- What is kept about who a visitor is, one setting at a time. New
web_analytics_store_ip(off/truncated/full),_store_user_agent,_store_headers,_store_networkand_store_signals, all off by default, write to onevisitor_profilesrow per visitor ID (never to an event row). Credential headers are never kept; rows go with the raw events’ retention.Profiles.forget/1takes stored data back, andAdmin.forget_profiles/2does the same with an activity-log entry, also available from Settings. - Visitor ID rotation (
web_analytics_visitor_rotation):daily(default),weekly,monthlyornever. Report visitors count daily uniques under every rotation; longer IDs let the visit list identify returning visits. - A bot score with reasons, and a Bots page that ranks profiles and groups them by network, subnet, address, device or User-Agent. The score is evidence only: nothing is dropped or blocked because of it.
- Device measurements from the client script (screen, time zone, graphics,
canvas, audio, fonts …) and a salted device hash, when
store_signalsis on. - Consent rules per kind of collection (
web_analytics_consent_*:always,consent,unless_objectedfor visits, visitor details, device measurements and recordings). Answers come from the Legal module’s banner or a hostconsent_source; a failing source reads as a refusal. Live pages follow a note the plug leaves in the session.web_analytics_without_consent: anonymouscounts a view with no visitor.track_event/2andtrack_pageview/1takeconn:. PhoenixKitWebAnalytics.data_collection/0declares what is collected to the Legal module’s banner and policy.
Fixed
- The test suite’s LiveView page tests used a
/en/admin/...base thatphoenix_kit2.62 no longer emits (primary locale is prefixless). - Raw and rolled-up reports now agree under every visitor-ID rotation, including visitor counts, exit visitors and monthly trends. Visit totals, bounce rate and average length consistently use daily portions of visits spanning midnight; visit timelines still show the full visit.
- Profile erasure removes address and User-Agent copies from request headers, changes data and derived scores atomically, and preserves unrelated bot evidence. Host-supplied header maps also enforce credential redaction, address-storage rules and query stripping.
- Incomplete device reports retain earlier measurements and compute the device hash and score from the merged data in the same transaction.
- Consent-rule and category changes apply to open LiveViews and delayed leaves. Visitor answer changes still require a full HTTP page load; Legal reloads on withdrawal by default, and host consent tools must do so too.
Web Analytics 0.7.0. Install or update: {:phoenix_kit_web_analytics, "~> 0.7"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.