1

Is there a way to get the total number of page views of a page in SharePoint using Rest API or JSOM?

I tried using Search API

http://SiteUrl/sites/_api/search/query?querytext='home'

But in all the results, the ViewsLifeTime is null I enabled search and crawl for the managed property (ViewsLifeTime) and ran a full crawl as suggested here, but still the values were null.

Also the ViewsRecent column is null as well

Is there any other way ? Am I missing something like a mapping?

4
  • ViewsLifeTime is updated around every 2 weeks while ViewsRecent shows visitors of the recent time span. Have you had your page at least for the couple of weeks so that ViewsLifeTime could have received some value?
    – moe
    Jul 26 '18 at 5:23
  • Yeah the page has been there for almost a month now. but I've enabled search & crawl in the managed meta data only today, does that matter? Jul 26 '18 at 5:24
  • ViewsRecent also returns null value. Not sure what I am missing Jul 26 '18 at 5:46
  • 1
    Yes it probably does matter that it's been put under crawling only recently.
    – moe
    Jul 26 '18 at 6:03
1

you could try using parameters:/_api/search/query?querytext='home'&selectproperties='Recent Views'

this site goes into pretty good detail of using the search api: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.