Loading

How to Count the Number of Times a Salesforce Knowledge Article Was Viewed by Internal Users Using SOQL

Udgivelsesdato: Jun 15, 2026
Beskrivelse

Salesforce Knowledge administrators may want to track article view statistics — such as how many times an article was viewed by internal users vs. external users — to help decide whether to archive, update, or promote certain articles.
Salesforce provides the KnowledgeArticleViewStat object, which stores view statistics for published and archived Knowledge Articles across different channels.

Løsning

Using the KnowledgeArticleViewStat Object

The KnowledgeArticleViewStat object stores per-article view statistics by channel — meaning the context in which the article was viewed. The two key fields are:

  • ViewCount: The number of unique views a published or archived article has received in the selected channel.
  • NormalizedScore: A normalized relevance score (between 0 and 1) that can be used for relative ranking of article popularity within a channel.

Available channels:

  • AllChannels — article views across all channels.
  • App — the internal Salesforce Knowledge application (used for internal user views).
  • Pkb — views in the public knowledge base.
  • Csp — views in the Customer Portal.
  • Prm — views in the partner portal.

How to Query Internal Article Views

To count the number of times each article was viewed by internal Salesforce users, use the App channel in the SOQL query. The App channel represents views from within the internal Salesforce Knowledge application.
To run this query:

  1. Open the Developer Console in Salesforce (Setup > Developer Console).
  2. Click the Query Editor tab.
  3. Enter the following query: SELECT id, ViewCount FROM KnowledgeArticleViewStat WHERE Channel = 'App'
  4. Click Execute.

This query returns a row for each published or archived Knowledge Article, with the unique view count for internal app views. To find the most-viewed articles, add ORDER BY ViewCount DESC to the query.
Note: The NormalizedScore field is also available on this object and provides a score between 0 and 1 reflecting the article's relative view popularity. You can include it in your query for additional context.

Vidensartikelnummer

000383653

 
Indlæser
Salesforce Help | Article