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
    CommentedJul 26, 2018 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?CommentedJul 26, 2018 at 5:24
  • ViewsRecent also returns null value. Not sure what I am missingCommentedJul 26, 2018 at 5:46
  • 1
    Yes it probably does matter that it's been put under crawling only recently.
    – moe
    CommentedJul 26, 2018 at 6:03

1 Answer 1

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

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.