+ Start a Discussion
JayantJayant 

Query on Article view stats

Hi All,

I am experiencing the following behavior on Salesforce Knowledge and would like to know if this is specific to me or everyone has this issue ?

I have Articles that are exposed on Internal App, Customer and PKB channels. I have a Customer community (that acts as an authenticated site) and several public force.com sites which all expose the articles for perusal by Customers.
Community and Force.com sites are entirely developed using VisualForce and no standard functionality is included.
When I view an article inside the Internal App using Article detail page or Article Management tab, the view statistics (in standard object - KnowledgeArticleViewStat) gets updated to reflect the same. But when I view the same articles on Community or PKB using custom VF solution, even though the Articles are shown as expected, the associated view stats do not get updated.

Also, if a user copies over the Article Id and browses to it by pasting the Id directly in address bar of browser, the user is still presented the article in standard community/force.com site styling and the view stats do get updated as expected.

I want to know why the stats don't get updated while interacting with Articles using VF ? and what could be done so that the stats start getting updated based on views from custom PKB or Community ?

Also, does everyone face this issue or its specific to my Org ?

Note - We don't use Knowledge specific VF components but the usual ones as its a completely customized look and feel.
Best Answer chosen by Jayant
JayantJayant
Found the solution.

Salesforce provides a SOQL clause that can trigger an update to the view stats for an Article.

Needed to append the clause to queries like - 

SELECT Title FROM FAQ__kav
WHERE PublishStatus='online' and
Language = 'en_US' and
KnowledgeArticleId = 'kA0190000000xyz'
UPDATE VIEWSTAT

UPDATE VIEWSTAT in a query causes the queried record's view stat to be updated. Channel is auto-selected based on the origin of query.

All Answers

Sumitkumar_ShingaviSumitkumar_Shingavi
Hello Jayant,

I think this is issue due to your implementation. Salesforce might be having some JS embedded which you are not able to look for keep track of view stats. You can inspect HTML and see how they increase count of view. There might be a JS function you can catch.

If you are doing standardStyleSheet=FALSE then you will not be able to see it as you said you have custom UI.

Hope this helps!
JayantJayant
Found the solution.

Salesforce provides a SOQL clause that can trigger an update to the view stats for an Article.

Needed to append the clause to queries like - 

SELECT Title FROM FAQ__kav
WHERE PublishStatus='online' and
Language = 'en_US' and
KnowledgeArticleId = 'kA0190000000xyz'
UPDATE VIEWSTAT

UPDATE VIEWSTAT in a query causes the queried record's view stat to be updated. Channel is auto-selected based on the origin of query.
This was selected as the best answer