OJS Usage Statistics

Hi @digitojs

Hmmm… strange… :-\

How are the URLs of your journals? The standard URLs like your-domain.com/index.php/journalPath ? Or have you maybe did any configuration to remove index.php or use other domains for journals or … ?

I think it is possible to reprocess the old stats, but I would first try it all in a test environment/copy…

Best,
Bozana

1 Like

Hi @bozana,

Thank you for your answer.
Your observation was precious because I noticed something.
In config.inc.php:

and in .htaccess, rules for “that” journal, and others:

  • RewriteRule ^journalPath(.*)$ /index.php/journalPath$1 [L]

I’ll add the base_urls for every journal and see how it processes.

To test the old stats I would appreciate your help but I want to adjust a test environment first.

Thank you,
Best Regards

Hello,

since the changes, it processes and counts the statistics of each journal. But only downloads, not page or abstract views. I’ve searched the forum but didn’t get the right procedure to display all the stats.

Thank you,
Best regards

Hi @digitojs

Hmmm… So what happens when you visit an abstract page? Do you see the correct URL in the usage statistics log? If you see that, do you see the entry for that date/log file in your DB table metrics with assoc_type = 1048585 and that submission_id?
In case you mean the graph displayed on the article page: there, only galley downloads are considered.
What do you mean with page views?

Best,
Bozana

Hi @bozana
Refer to what you have explained, I have checked my file_dir and DB
In my file_dir, I found ScheduledTaskLogs folder contains (top bottom)

In my DB, I found in metric table

and scheduled task as follow

Download stats is displayed Pengembangan perangkat pembelajaran matematika dengan pendekatan kontekstual budaya Lombok | Beta: Jurnal Tadris Matematika
My questions are:

  1. What I found in file_dir and DB, do they look normal?
  2. How abstract views can also be displayed in my journal?

I am using 3.0.1
Thanks

I have read your suggestions in this Article statistics showing 0 abstract views and 0 PDF downloads - #2 by bozana

(1)
The code changed in OJS 3.0.1, so it cannot be used as it is. You will have to change the function getViews in classes/article/ArticleGalley.inc.php to be like this:

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

DONE

(2)

Furthermore, there is currently no getViews function for articles. If you want to use it, you will have to add the following function to your classes/article/Article.inc.php:

function getViews() {
	$application = PKPApplication::getApplication();
	return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION, $this->getId());
}

I HAVE ADDED IT

For (3) and (4) I don’t understand

(3)
Also, you do not need the line {if is_a($article, ‘PublishedArticle’)}… in article_details.tpl, so there it should be something like:

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

(4)
In issue_toc.tpl (or article_summary.tpl) you would maybe need that line, but not at that place, but rather something like this:

{if is_a($article, 'PublishedArticle')}{assign var=galleys value=$article->getGalleys()}{/if}
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} | {$galley->getViews()} | times
{/foreach}
{/if} 

in article_details.tpl, I don’t find (3) I only find

Hi @bozana,

The metrics table has the assoc_type = 1048585 and the submissions ID, its being processed correctly. What do you suggest the best way to display them?
Sorry for the misleading “page views”, I was refering to the journl views.

Thank you,
Best regards

Hi @kawahyu

Yes, your DB table metrics looks normal :slight_smile:
And yes, in order to display the abstract views you would need the getViews function in the Article class. Depending where you want to display it, you would need to change the smarty template, to add the code {$article->getViews()} assuming that the $article variable is assigned to that template.
The 3) and 4) from above is the code example, that one could insert into the smarty templates article_details.tp i.e. issue_toc.tpl in order to display the the article and galley views on the article page i.e. on the issue TOC page.

Best,
Bozana

Hi @digitojs

You would need to make some changes in the code, s. the post from kawahyu and my answer here – you would need to add the getViews function in the Article class and then call it in the wished smarty template, e.g. article_details.tpl… (I am not sure what you would need to change to consider and/or display it in the graph…)

Best,
Bozana

I am trying to understand it since I am just a journal editor.
For the following codes (3)

{translate key=“article.abstract”} viewed = {$article->getViews()} times
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} | {$galley->getViews()} | times
{/foreach}
{/if}

Do I just put them at the top bottom of all codes in article_details.tpl? Or I adjust with the codes
{* Abstract *}


that I find in article_details.tpl?

you could insert that code for example here: https://github.com/pkp/ojs/blob/master/templates/frontend/objects/article_details.tpl#L137

But you would also need to move this line https://github.com/pkp/ojs/blob/master/templates/frontend/objects/article_details.tpl#L209 in front of that code that you are , i.e. something like:

{translate key=“article.abstract”} viewed = {$article->getViews()} times
{assign var=galleys value=$article->getGalleys()}
{if $galleys}
{foreach from=$galleys item=galley name=galleyList}
{$galley->getGalleyLabel()} | {$galley->getViews()} | times
{/foreach}
{/if}

If you do not need the galleys counts, you can only use this:

{translate key=“article.abstract”} viewed = {$article->getViews()} times

2 Likes

Hi @bozana
I have inserted the codes in article_details.tpl and moved the

{assign var=galleys value=$article->getGalleys()}

In my article_details.tpl, it is as follow

After saving, I have not seen any abstract view stats in article display Membangun koneksi matematis siswa dalam pemecahan masalah verbal | Beta: Jurnal Tadris Matematika

Anything missed?

Hi @kawahyu

Hmmm… Your article view page looks different than the standard OJS. Did you maybe make some changes, do you use another theme or so?

Best,
Bozana

I use Manuscript Jats Theme by @Vitaliy. Is there any effects for the abstract views?
Wish @Vitaliy has chance to give any words
I will try another theme, see what is the result

Hi @bozana
The statistics are displayed in default theme. But, the format is not set well I think.
http://jurnalbeta.ac.id/index.php/betaJTM/article/view/83
Any idea to fix them?

@kawahyu

This is what that code part does. How would you like to have them? – It is not easily possible to display them in a graph, just as a text…

For the other theme: you would need to find the template in that plugin folder, that you need to change…

A text is fine.

Abstract viewed = 0 times PDF (Bahasa Indonesia) | 231 | times

Does 231 refer to PDF view?
Could I customize to be like?

Abstract viewed = 0 times | PDF (Bahasa Indonesia) viewed = 231 times

I think, abstract view does not work

It seems {translate key=“article.abstract”} viewed = {$article->getViews()} times refer to Abstract viewed = 0 times.

Are the codes for customizing PDF (Bahasa Indonesia) viewed = 231 times in artcle_details.tpl?

@kawahyu

One change: The funciton in ArticleGalley class should look like this: pkp/pkp-lib#2167 fix assoc type in getViews for article galleys · pkp/ojs@32c6678 · GitHub
Apparently you do not need the getView function in the Article class, because there is that function in the PublishedArticle class.

Concerning abstract views = 0: Apparently you do not have any entries in your DB table metrics with assoc_type = 1048585 and assoc_id = 83 (the article example you are looking at) from this year. But there are some views for article 1, s. Efektivitas pembelajaran matematika melalui penerapan model pembelajaran kooperatif tipe snowball throwing | Beta: Jurnal Tadris Matematika.
You would need to investigate why are there no entries for article 83 – maybe they will come in a day or so…

This code displays the galley views:

{$galley->getGalleyLabel()} | {$galley->getViews()} | times

Thus change it to:

{$galley->getGalleyLabel()} viewed = {$galley->getViews()} times

to get the text you wish…

maybe they will come in a day or so…

I hope so. Just wait another day

I think the usage event log does not show real time access in DB metrics. Today is 28-07-2017 but it shows 27-07-2017
Is it normal?