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

Popularity files

Solved by Andy Miller View solution

Started by jean-louis67 2 days ago · 2 replies · 76 views
2 days 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
2 days ago Solution

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.

2 days ago

Thank you very much for your prompt response, your explanations and advice, and for the continuity of this data between Grav1 and Grav2.

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 6 days ago
0 143 6 days ago
General · by Veehem, 1 week ago
0 142 1 week ago
General · by milkboy, 1 week ago
0 137 1 week ago
General · by ian russell, 2 weeks ago
2 225 2 weeks ago
General · by pamtbaau, 1 month ago
2 480 3 weeks ago