Lightweight post view tracking with day, week, month, year, and multi-year breakdowns. No external services. No bloat.
- 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
Milner Stats gives you simple view tracking for your posts and pages.
- 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 tags —
wms_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.
[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"]
<?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| 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 |
- Upload the
milner-statsfolder to/wp-content/plugins/— or install directly via Plugins > Add New > Upload Plugin. - Activate the plugin through the Plugins menu in WordPress.
- 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.
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).
- 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.
- Bug fixes.
- Import from Jetpack.
- Fixed a bug that meant Milner Stats only kept stats for 1 year.
- Bar graph instead of line graph.
- Initial release.