Odometer for Craft CMS

Installation

Requirements

  • Craft CMS 5.3 or later
  • PHP 8.2 or later
  • MySQL 8 / MariaDB 10.5 / PostgreSQL 13 or later — whatever Craft itself is running on

Nothing else. Odometer has no runtime dependencies beyond Craft's own, makes no outbound requests, and has no build step.

Install

composer require justinholtweb/craft-odometer
php craft plugin/install odometer

Or find Odometer in the Plugin Store and press Install.

That is the whole setup. Every front-end page that resolves to an element is counted from then on, with a half-hour dedupe window, robots ignored and Do Not Track honoured.

What it adds to your database

Two tables:

  • odometer_totals — one row per element, per site, per counter. The lifetime number.
  • odometer_daily — one row per element, per site, per counter, per day.

Both cascade from elements and sites, so deleting an element or a site takes its counts with it and leaves nothing orphaned.

There is no third table. Odometer does not store a row per view, an address, a session, or anything else about a person — see the FAQ.

Rough size: a site with 5,000 URLs that is read every day accumulates about 1.8 million day-bucket rows a year, which is roughly 90 MB. Retention defaults to 730 days and prunes the rest.

If your site is behind a full-page cache

Blitz, Varnish, a CDN, craft\web\Response caching — anything that serves a page without Craft running. Switch Settings → Odometer → How views are counted to With a beacon.

In auto mode Craft only runs for the first reader, so the count becomes "how many cache misses happened", which is a number that looks plausible and is wrong. The beacon moves the count into a second request that always reaches Craft.

You do not need to do anything else: the beacon is added to front-end pages automatically. If you would rather place it yourself, turn Add the beacon automatically off and put {{ craft.odometer.beacon(entry) }} where it belongs.

Uninstalling

php craft plugin/uninstall odometer

This drops both tables. Every count goes with them, and there is no way back — export first if the numbers matter:

php craft odometer/views/top --period=all --limit=100000 > views.txt

or use Odometer → Popular → Export CSV, which gives you a spreadsheet per site.