Views Work v1.3
Track pageviews and content popularity in Craft CMS
More Craft plugins

Resetting daily, weekly, monthly views

Some view counters need to be reset periodicaly. You can do this either with a cron job, or with a service like easycron if you don't have access to cron jobs (the latter service would use a special url to reset the views).

Here's how.


With a cron job

To reset the daily, weekly and monthly view counters, you need to run a cron job once a day.
The plugin automatically detects wether it is the first of the month, week and resets the appropriate counters.


# The command to execute:
php /path_to_project/craft views-work/default/reset-views

# Example of a line in crontab:
5 0 * * * php /path_to_project/craft views-work/default/reset-views

With a special url

If you do not have access to cron jobs, you can enable a special url in the plugin settings that you can call, to reset the daily and other periodic views.

Here's a screenshot of wat the settings page might look:


EASYCRON

Easycron offers a service where you can execute crons through urls. Configuration by url at easycron would look like this (note the 'POST' method, this is the default for Views Work. POST methods are outside easycron's free plan though. In that case, you can allow GET methods in the plugin settings. Be carefull though not to accidently enter the url in your browser, since it will execute the reset)