Extract the number of views for each article on a SharePoint site

Kinasz, Mateus 60 Reputation points
2023-10-24T10:38:30.76+00:00

Hi,

I have a site within SharePoint with articles and I would like to extract the number of views for each article in an automated way, preferably with an AWS lambda function.

I tried reportRoot: getSharePointSiteUsageDetail using Graph API; however, it appears that it is only possible to extract the total number of views for a site and not for each article.

Someone asked a similar question in the forum:
I would like to get information on the number of views of all files under a specific folder in SharePoint Online via REST API

It seems possible to use the REST API to obtain the information needed.
I am asking 2 questions:

  1. Is it possible to extract the number of views for each article?
  2. If so, what permissions are required to extract the data, such as registering an Azure application or giving permission to that application?
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor
    2023-10-25T02:50:51.2066667+00:00

    Hi @Kinasz, Mateus

    Per my test, I could get view count by search/query. For recently viewed page you can use "ViewsRecent" and while "ViewsLifeTime" is update every 14 or 15 days.

    https://tenant.sharepoint.com/_api/search/query?querytext='*'&rowlimit=10&sortlist='viewsrecent:descending'
    

    Here is the test result

    User's image

    For the permission level, you could refer to the following issue similar with yours

    https://stackoverflow.com/questions/66481828/how-to-query-the-sharepoint-rest-api-not-the-graph-api-using-an-azure-ad-regis


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful