Let's fix SharePoint Search together!

How to interpret SharePoint’s view count managed properties (like “ViewsLast1Days”)?

Have you ever wondered, how SharePoint’s Managed Properties for Usage & Analytics info actually work? There are all these nice properties available for getting view counts for different items in SharePoint’s search index, but they all seem to act like crazy. And they are pretty nonsensical… And not very well documented!

In this post I’ll try to make some sense on how you can use them in programmatic scenarios. Read on…

What properties are we talking about?

Ah, yeah. That might be a good way to start the post. We’re talking about all the managed properties, that SharePoint populates for view counts. There really is a bunch of them, and while they’re not very reliable, they might still be useful for fetching the most popular stuff or comparing usage/views of certain items over time.

Over very limited, predefined time, that is. Anyway, let’s look at the list of properties, and what do they mean!

View Count -related Managed Properties in SharePoint Search schema
View Count -related Managed Properties in SharePoint Search schema

In this post, I’m skipping using the “Unique” -versions of the properties. They’re typically measuring unique users instead of views – but in this example, we’re more interested in view counts, and what do they mean.

How to browse the values for view counts in your environment?

You can access this url to get the view counts for items in your intranet site – feel free to modify it to apply different filtering:

https://[your_intranet_sitecollection_root_url]/_api/search/query?querytext=%27Path:https://[path_to_your_intranet_site]*%20(contentclass=STS_Site%20OR%20contentclass=STS_Web)%27&selectproperties=%27Title,ViewsLast1Days,ViewsLast2Days,ViewsLast3Days,ViewsLast4Days,ViewsLast5Days,ViewsLast6Days,ViewsLast7Days,ViewsRecent,ViewsLastMonths1,ViewsLastMonths2,ViewsLastMonths3,ViewsLifetime,Path%27&orderBy=ViewsRecent&trimDuplicates=false&rowlimit=500

This query basically returns you all web or site home pages with their titles, paths and all available usage properties. As a result, you get something like this (example is a home page of a site):

SharePoint Search Managed Properties for viewcounts
An excerpt of the results that SharePoint Search Service API returns. Selected are the Managed Properties for view counts

So, what do these managed properties actually contain?

List of Usage-related managed properties in SharePoint Search Index

You can get the unique views (supposedly, only one per user, but this is probably more like one per sticky session and not actually user-related at all) by appending “UniqueUsers” or “Unique” at the end of the property name. More precisely, for all the other properties, append “UniqueUsers”, but for month-related properties, append “Unique”.

So, the total list of all properties is something like this:

  • ViewsLast1Days
  • ViewsLast1DaysUniqueUsers
  • ViewsLast2Days
  • ViewsLast2DaysUniqueUsers
  • ViewsLast3Days
  • ViewsLast3DaysUniqueUsers
  • ViewsLast4Days
  • ViewsLast4DaysUniqueUsers
  • ViewsLast5Days
  • ViewsLast5DaysUniqueUsers
  • ViewsLast6Days
  • ViewsLast6DaysUniqueUsers
  • ViewsLast7Days
  • ViewsLast7DaysUniqueUsers
  • ViewsLastMonths1
  • ViewsLastMonths1Unique
  • ViewsLastMonths2
  • ViewsLastMonths2Unique
  • ViewsLastMonths3
  • ViewsLastMonths3Unique
  • ViewsLifeTime
  • ViewsLifeTimeUniqueUsers
  • ViewsRecent
  • ViewsRecentUniqueUsers

It’s kind of weird how inconsistent this naming is just in general… But hey, it’s SharePoint 🙂

Here’s the list with explanations and example values (I’m omitting the Unique-versions to keep it concise):

Property NameCollection time scopeExample value in a typical situation (intranet for a small organization, observation day: Wednesday in September)Explanation
ViewsLast1DaysNon-cumulative; just the value for one day.351Views of the last full day – in our case, Tuesday.
ViewsLast2Days375Views of the day before the last full day, so in our case, Monday.
ViewsLast3Days15Views of the day before; in our case, Sunday.
ViewsLast4Days6Views of just Saturday. You know, a day before the last one.
ViewsLast5Days275Friday. The same thing as before.
ViewsLast6Days472Thursday. You know.
ViewsLast7Days468Wednesday.
ViewsRecentCumulative: 2 weeks (14 days, not calendar weeks)1042All of the views of 14 last full days lumped together. However, on-premises this is configurable to be whatever between 1-14 days.
ViewsLastMonths1Cumulative: A full (calendar) month1278All of the views of the last full month (e.g. August).
ViewsLastMonths21329All of the views of the previous full month (e.g. July).
ViewsLastMonths31476All of the views of a month before the one above (e.g. June).
ViewsLifetimeCumulative: Lifetime85445Sum of all the views since the document was created.

These are based on a combination of shoddy documentation and my unreliable observations. Probably goes without saying, that I’m not 100% sure of all of the details.

More info about the property names etc., although I don’t think they’ve gotten all of the descriptions quite right:

SharePoint Search: Get Usage data from search

How to interpret the values for different properties?

Looking at the example values and explanations before, we can see a few trends from these values. Just from these values, you can quite clearly see the weekend and vacation season (drop in page loads for August). These are very typical for Intranet sites, and you can verify the same trends using a more refined analytics solution (like Google Analytics).

If you want to count together views for last 3 days, you need to calculate:

ViewsLast1Days + ViewsLast2Days + ViewsLast3Days

Similarly, counting visits for last 2 months (in our example, August + July), you’d need to sum together:

ViewsLastMonths1 + ViewsLastMonths2

I don’t know if the naming scheme bothers anyone else, but I think it’s pretty bad. It’s notoriously difficult to change something like that, though, so it’s entirely possible, that Microsoft has changed how the properties work at some point without changing the names.

More info: https://social.technet.microsoft.com/Forums/sharepoint/en-US/6793cffa-14f1-4318-9e02-40e287dfa5ec/timespan-of-search-usage-properties-views?forum=sharepointsearch

Caveat: Sums are not always actually sums.

Because of something called tail-trimming, SharePoint doesn’t actually calculate view counts for days, when view counts are low. Theoretically, only days with really low (under 3) views per day should be omitted from all values, but like with so many other things in SharePoint, I would take this with a grain of salt. Sums of different viewcounts won’t match, though, that’s for sure.

Problem: All of these property values are null!

Ruh-roh! That’s pretty typical. Might be worth another article, but a couple of quick pointers:

  • Are you on-premises? You’re either missing mappings, your usage & analytics service is down, you’re out of disk space on crawler/indexing application server, or something similar.
  • Are you in O365? Try Using SharePoint Search Query Tool to check if the properties are available and have values. Export a Excel report from Usage / popularity trends to see if the usage service is down. If the report doesn’t work either, open a ticket at Microsoft support.

 

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

Let me know your thoughts!