Skip to content
Grav 2.0 is officially stable. Read the announcement →
General

Popularity files

Started by jean-louis67 12 hours ago · 1 replies · 28 views
12 hours ago

With Grav1, I used to retrieve the daily.json and montlhy.json files from the logs/popularity directory every day to process them and present statistics. It seems that since Grav2, these files are no longer produced.

last edited 08/04/26 by jean-louis67
6 hours ago

Nothing was lost, it just moved and consolidated.

Page-view tracking used to be part of the classic admin plugin, which Grav 2 no longer uses. It now lives in the API plugin, and instead of four separate files it writes one combined file:

logs/popularity/popularity.json

Same directory as before. The contents cover everything the old files did:

JSON
{
  "version": 2,
  "daily":    { "2026-08-03": 42 },        // was daily.json
  "monthly":  { "2026-08": 1180 },         // was monthly.json
  "pages":    { "/blog/my-post": 61 },     // was totals.json
  "visitors": { "<ip-hash>": 1754236803 }  // was visitors.json
}

Two things worth knowing if you're scripting against it:

  • Date keys are now ISO (YYYY-MM-DD and YYYY-MM) rather than d-m-Y, so they sort correctly and don't depend on locale.
  • The first time the new code runs on a site that still has the old files, it imports them and renames them to *.migrated, so your historical numbers carry over.

Settings are under user/config/plugins/api.yaml:

YAML
popularity:
  enabled: true
  exclude_admin: true
  exclude_ips: []
  history:
    daily: 30
    monthly: 12
    visitors: 20

If you'd rather fetch the stats over HTTP than read the file off disk, the API plugin also exposes GET /api/dashboard/popularity (requires the api.system.read permission), which returns today/week/month totals, a 14 day chart series, and the top 10 pages already aggregated for you.

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 4 days ago
0 130 4 days ago
General · by Veehem, 6 days ago
0 135 6 days ago
General · by milkboy, 6 days ago
0 130 6 days ago
General · by ian russell, 2 weeks ago
2 219 2 weeks ago
General · by pamtbaau, 1 month ago
2 473 3 weeks ago