OJS usage stats

I’ve been searching for a guide on how to get article usage stats and I found this code, but no explanation how to use it.

ojs/MetricsDAO.inc.php at ojs-stable-2_4_8 · pkp/ojs · GitHub

I’ve seen OJS on a couple of Journals with neat graphs under articles that identify (1) total views (2) abstract views (3) pdf views and (4) html views per month and year
Is there a simple how to guide to get an outcome like the websites identified through this thread

Abstract views, PDF views and Download Stats Made Public 😶 - #3 by Dein

They mention ALM, but the project appears gone now, it is deprecated?


Hi @MarkAGregory

You could use Usage Statistics Plugin, but it does not display the statistics on the article page – this part you would then need to add/adapt by yourself for now…


thx Bozana for the suggestion. We’re hoping to not have to build the code again, it appears to have been done by others. We’re happy to contribute to someone that helps us get this going.

Mark Gregory

Hi @MarkAGregory

You can use the code part from the blog post you mentioned above, to display the counts as a text – that change is not big…


Hi Bozaba, have you done it? Even a text solution would be good. Are you
able to give me the steps?

Hi @MarkAGregory,

If you are using Usage Statistics Plugin and have the statistics in the DB table metrics, then you should do the change described here to display the views on the article page: Abstract views, PDF views and Download Stats Made Public 😶 - #7 by beghelli – i.e. you should add that part of the code at in the template article.tpl.


Hi Bozana,

I have the usage statistics plugin enabled. How do I check the next step - DB table metrics?

Hi @MarkAGregory

Also the plugin Usage Event has to be enabled – it will generate/trigger an event, when user accesses the journal and article page.
The usage events are then logged by the Usage Statistic plugin in the log files under file_dir/usageStats/usageEventLogs/.
Furthermore, you will need either a Cron job or Acron plugin that will then trigger the processing of those log files, where the statistics are calculated and saved in the Database table metrics. The final counts are in the DB table metrics.
Thus, if you have done and setup everything properly, you can take a look in your Database table metrics, if you see there the counts.
Please see also this document for more information: https://pkp.sfu.ca/wiki/index.php?title=PKP_Statistics_Framework#Statistics_Logging.

Once the counts are in the metrics table, you can use the code above to display them on the article page.


Hi Bozana, I have checked usage statistics plugin is turned on and there is one log file in file_dir/usageStats/usageEventLogs/
I have Acron plugin enabled.
there is a table called metrics that appears to have a large number of entries

How do I add the code to display on an article page?
and just to be sure we’re talking about the code by gtgraham on Oct 16 near the bottom of the page being added to article.tpl

I could do with some help to get the statistics - the final step is possibly something I need help to be guided through.

Hi @MarkAGregory

It sounds good.
Only the values with the metric_type = ojs::counter are considered in the Usage Statistics Plugin – there could be also ojs::legacyCounterPlugin, ojs::timedViews and ojs::legacyDefault from the older plugins that does not count here.

I do not know what code by ctgraham do you mean… but you would then use this code:

{translate key="article.abstract"} - {$article->getViews()}
{if $galleys}
        {foreach from=$galleys item=galley name=galleyList}
                {$galley->getGalleyLabel()} - {$galley->getViews()}

as posted here: Abstract views, PDF views and Download Stats Made Public 😶 - #7 by beghelli

Yes, in the templates/article/article.tpl file.


thx Bozana, I’ve added it and will monitor to see how it works over time. I’m trying to work out in another thread to get country statistics working and I need to be able to get the statistics for a particular IP (institutional subscribers). So much to setup!