Hello @jhtjards,
I’m sorry for the late reply. I replied earlier, but somehow it seems to have been lost as I’m not seeing it now…
Koko Analytics writes all pageviews to a temporary buffer file which is then periodically (every minute, by default) processed at which point the pageviews are added to the current date in your database. The plugin currently runs this process every minute OR whenever you load the dashboard. It seems that in your case, the file is only processed in the latter case (whenever you view your dashboard).
This usually happens when your WP Cron is not working as expected OR some other scheduled action is throwing a fatal error and therefore blocking the queue. Some pointers which should help you resolve this:
Let me know if that helps please.
Hi Danny, thanks for your ideas!
WP Cron seems indeed the culprit. Investigating the error log I found
Cron reschedule event error for hook: koko_analytics_aggregate_stats, Error code: could_not_set, Error message: Could not save cron event list., Data: {"schedule":"koko_analytics_stats_aggregate_interval","args":[],"interval":60}
There were more errors like this from other plugin’s schedules, so I don’t think koko analytics is at fault here.
I researched a bit and checked file permissions as well as a check for database issues (Did a “REPAIR” and “OPTIMIZE” on wp_options table). I couldn’t find anything wrong. WP Cron runs normal, if I’m logged in.
Maybe a weird server issue (It’s a litespeed server, no caching enabled from within WP).
So next I’ve set up a real server cron job now to run every 5 minutes and disabled wp-cron in wp-config.php.
I’ll report back in a few days if this helped or not.
Hey @jhtjards,
Nice work! Replacing WP Cron with an actual cronjob is a solid idea, I’d definitely recommend it. Note that if you have WP CLI installed then you can also set up a separate cronjob that runs the Koko Analytics aggregation step directly, something like:
wp cron event run koko_analytics_aggregate_stats
Or using the built-in WP CLI command:
wp koko-analytics aggregate
Let me know whether it’s fixed please.
Hi Danny,
I haven’t set up wp cli on that site and hoster, so I kept the cron job like described before (using wget and the cron url at https://domain.com/wp-cron.php?doing_wp_cron)
After 4 days not touching the site, I can confirm the fix works. Nice aggregation of stats on each day – beautiful.
Thanks again for your help and suggestions!
Awesome, happy to hear it @jhtjards.
We’ll improve on our end as well by making sure any stalls will still eventually result in data being added to the right day.
Best, Danny