User view count

I use ojs, and I have a question about view count about abstract and pdf view
I set function for both of them, but now, I see after clicking on it, its counter doesn’t change correctly. I think after one click it should be plus +1 but it doesn’t change!
for example when I publish a new issue, some submission after 600 view click, the counter shows just 59 view ?!

Function getview in

function getViews() {
	$application = Application::getApplication();
	$fileId = $this->getFileId();
	if ($fileId) {
		return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $fileId);
	} else {
		return 0;


Can anyone help me?
Its a bad problem for me and I can not handle it yet!

Hi @mbabaei,

The statistics system doesn’t increment a counter when someone views an article; it logs requests for articles and processes them on a batch basis to generate an updated count. This is necessary because the statistics system is based on the COUNTER standard, which requires features like debouncing of multiple quick requests by the same user, filtering of bots, etc., which can’t be done with a simple counter.

Generally stats are processed on a 24-hour cycle.

If you’re not seeing requests being counted as you expect after 24 hours, the most likely cause is that the log file parser doesn’t recognize log entries as requests for your journal’s articles. A common cause of that is that the URLs don’t match, i.e. your base_url configuration in doesn’t match the URLs being used to read your journal articles.

Alec Smecher
Public Knowledge Project Team

Thank you very much for your answer.

Yes your right, and I want to know that, how and when run this batch on my server?! because I never set any crontab for it!

And what is these queries?
I think its return download count:
"SELECT SUM(metric) AS metric FROM metrics WHERE assoc_id = ‘357938’ AND assoc_type = 515 AND context_id = ‘28’ AND metric_type = ‘ojs::counter’ "

and its return view count:
"SELECT SUM(metric) AS metric FROM metrics WHERE assoc_id = ‘68143’ AND assoc_type = 1048585 AND context_id = ‘28’ AND metric_type = ‘ojs::counter’ "

But I have another question, how and when the ojs insert a new row in metric table, for new download or view article?

I face same problem. I think this is solution when you know where is code for insert into command for metrics table.

Please write here if you know the solution

Hi @mbabaei,

The log file processing gets started either by a cron job, or by the acron plugin.

Alec Smecher
Public Knowledge Project Team

1 Like