Web Analytics 0.2.0: Cookieless analytics for PhoenixKit, without a script tag
Web Analytics 0.2.0 gives a PhoenixKit site its own visitor analytics, counted on the server: no script tag, no cookies, no IP addresses stored, and the data stays in your own database. It is the first version of the package published on Hex.
How it counts
One plug in the :browser pipeline records each page view after the response is sent. A visitor is a salted hash of the IP address and the browser that changes every day, so no IP is written to the database. Page views are grouped into visits by a 30-minute gap. Bots, excluded paths, requests other than GET, error pages and visitors sending Do Not Track or Global Privacy Control are skipped. Campaign utm_* parameters are kept; the rest of the query string is not.
A LiveView hook counts navigation inside a LiveView page, which the plug cannot see. Optional endpoints, off by default, accept a small beacon for custom events from the browser and a pixel for cached pages.
What the admin shows
A Web Analytics section with six pages:
- Overview: visitors, page views, visits, bounce rate, average visit and server response time, each compared with the previous period, with the traffic trend.
- Pages: paths by views, and the slowest pages.
- Acquisition: channels, referring sites and UTM campaigns.
- Technology: browsers, systems, devices, languages and countries.
- Events: custom events and a live feed of recent hits.
- Settings: collection rules, retention and an installation checklist.
Period and site filters live in the URL, so a report can be bookmarked. Raw events are kept for 365 days by default and rolled up into daily totals first.
Upgrading
Web Analytics 0.2 needs PhoenixKit 2.0. Add {:phoenix_kit_web_analytics, "~> 0.2"}, run mix phoenix_kit.update to create the two tables, add plug PhoenixKitWebAnalytics.Plug to the :browser pipeline, and turn on Web Analytics on the admin Modules page. For LiveView navigation, add {PhoenixKitWebAnalytics.LiveHook, :track_navigation} to your live sessions’ on_mount and expose :peer_data and :user_agent in the socket’s connect_info.
Full release notes: Web Analytics 0.2.0
0.2.0 · 10 August 2026
Changed
-
⚠️ Requires
phoenix_kit ~> 2.0. The core pin moved to~> 2.0, so this release no longer resolves against core 1.7.Core 2.0.0 squashes the migration chain into a single
V135baseline and makes V135 the chain’s floor:mix ecto.migratenow refuses on a database below it rather than migrating. Checkmix phoenix_kit.statusbefore upgrading. A host below V135 must installphoenix_kit 1.7.236— the migration bridge, the last release carrying the full pre-squash chain — migrate until the reported version is at least V135, and only then move to 2.0.This package does not call migration internals, so the change is the pin itself.
Fixed
- This is the first release of this package to actually reach Hex. Its
package
files:list named aprivdirectory that does not exist, andmix hex.buildrefuses to build a package whose declared files are missing (“Missing files: priv”) — so every publish attempt had failed before reaching the registry. The entry is dropped; add it back ifpriv/ever gains content. - The dashboard no longer fails to compile against core 2.0. Core 2.0 added
PhoenixKitWeb.Components.Core.Chart.bar_chart/1, which every LiveView imports viause PhoenixKitWeb, :live_view. That collided with this package’s own same-aritybar_chart/1, making the unqualified call in the dashboard ambiguous and failing the build. The local component is renamedtraffic_chart/1; core’s is a generic SVG chart keyed onid/data, while this one is bucket-aware and takesseries/metric/bucket, so they are not interchangeable and the local one is kept. Rendered output is unchanged. Callers using <code>PhoenixKitWebAnalytics.Web.Components.bar_chart/1</code> directly must rename the call.
Web Analytics 0.2.0. Install or update: {:phoenix_kit_web_analytics, "~> 0.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.