Skip to content

jeffmilner/Milner-Stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Milner Stats

Lightweight post view tracking with day, week, month, year, and multi-year breakdowns. No external services. No bloat.


Metadata

  • Contributors: Jeff Milner
  • Tags: stats, analytics, post views, popular posts, trending
  • Requires at least: 5.8
  • Tested up to: 7.0
  • Stable tag: 1.1.5
  • Requires PHP: 7.4
  • License: GPLv2 or later

Description

Milner Stats gives you simple view tracking for your posts and pages.

Key Features:

  • View tracking — Counts page views for all post types using a non-blocking JS beacon.
  • Time-period breakdowns — Day, week, month, and year views for every post.
  • Trending posts — Identifies posts with unusual traffic spikes vs. their 30-day average.
  • Admin dashboard — Full stats page with an interactive Chart.js activity graph and sortable top-posts table.
  • Dashboard widget — A quick stats summary on the WordPress dashboard home.
  • Admin bar — View count for the current post shown in the top toolbar.
  • Post list columns — View counts in the Posts and Pages admin list tables (sortable!).
  • Editor meta box — Per-post stats panel with a 14-day sparkline in the block editor.
  • Sidebar widget — Display Popular Posts in any widget area with full customization.
  • Shortcodes[wms_views] and [wms_top_posts] for use anywhere in content.
  • Template tagswms_get_views(), wms_the_views(), wms_has_views() for theme developers.
  • CSV export — Download your stats as spreadsheets (top posts, daily totals, raw data).
  • Settings page — Configure tracked post types, deduplication window, and admin exclusion.
  • Caching plugin compatible — Works with WP Rocket, W3 Total Cache, WP Super Cache, LiteSpeed Cache.
  • Privacy-friendly — IP addresses are one-way hashed, never stored in plain text.
  • Bot detection — Automatically skips crawlers and search engine bots.
  • No external services — All data stays in your WordPress database.
  • Automatic cleanup — Daily cron job removes records older than 366 days to keep the DB lean.

Usage

Shortcode examples:

[wms_views]                                   — Views for the current post (all-time)
[wms_views period="week"]                     — Views in the last 7 days
[wms_views id="42" label="Views: "]           — Views for post ID 42 with a label
[wms_top_posts]                               — Top 5 posts this week
[wms_top_posts period="month" limit="10" show_count="true"]

Template tag examples:

<?php wms_the_views(); ?>                         // Echo all-time views
<?php echo wms_get_views( null, 'week' ); ?>      // Get this week's views as integer
<?php if ( wms_has_views() ) { ... }  ?>          // Conditional: post has been viewed

Available REST endpoints (Admin only):

Method Endpoint Description
GET /wp-json/milner-stats/v1/stats Summary counts
GET /wp-json/milner-stats/v1/stats/posts Top posts by period
GET /wp-json/milner-stats/v1/stats/chart Time-series chart data
GET /wp-json/milner-stats/v1/stats/post/{id} Per-post counts + chart
GET /wp-json/milner-stats/v1/stats/trending Trending posts
POST /wp-json/milner-stats/v1/track Record a view (public)
POST /wp-json/milner-stats/v1/cache/flush Flush stats cache

Installation

  1. Upload the milner-stats folder to /wp-content/plugins/ — or install directly via Plugins > Add New > Upload Plugin.
  2. Activate the plugin through the Plugins menu in WordPress.
  3. Navigate to Milner Stats in your admin sidebar.

The plugin creates {prefix}_wms_post_views, {prefix}_wms_referrers, and {prefix}_wms_outlinks tables on activation. No additional configuration is required.


FAQ

Does this work with caching plugins? Yes. The tracker uses JavaScript fetch() / sendBeacon(), which fires after the page loads from cache.

Will it slow down my site? No. The frontend tracker script is tiny (~1 KB) and fires via requestIdleCallback. It has zero impact on page load time or Core Web Vitals.

Does it track logged-in admins? By default, views from users with edit_posts capability are excluded. This is configurable in Settings.

Does it store IP addresses? No. IP addresses are processed through a one-way SHA-256 hash with a site-specific salt.

What does "Trending" mean? A post is trending when its views in the last 24 hours are $\ge 2.0$x its daily average over the past 30 days (minimum 3 views today).


Changelog

1.1.5

  • Diagnostics: added pulldown to show 10, 25, or 50 most recent Internal Referrer Records (default 10).
  • Added Trending Now sidebar widget showing posts with unusual 24-hour traffic spikes.

1.1.4

  • Bug fixes.

1.1.3

  • Import from Jetpack.

1.1.2

  • Fixed a bug that meant Milner Stats only kept stats for 1 year.

1.1.1

  • Bar graph instead of line graph.

1.0.0

  • Initial release.

About

A Wordpress plugin to keep track of view statistics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors