0

I'm trying to see the most viewed blog posts in a SharePoint farm. So I just query for:

https://sharepoint/_api/search/query?querytext='ContentTypeId:0x0110*'

To get the ViewsLifeTime I have to include it as a sorting parameter. When I don't add a ViewsLifeTime sort, ViewsLifeTime is null. Is that the correct behavior?

https://sharepoint/_api/search/query?querytext='ContentTypeId:0x0110*'&sortlist='ViewsLifeTime:Descending'

Now this works for blog posts in one Web Application, but blog posts on the MySite WA never have ViewsLifeTime or ViewsRecent populated - they are always null. I do know that the blog posts are above the TailTrimming limit.

  1. When are these View-Events generated? Like what is the flow? User opens blog post > Usage event > Seach crawl > I can see the view event? Is search the only thing that needs to run or is there some timer job?
  2. Why do I get usage events in one web application, but not the other? Do I need to change timer jobs? Service associations? Web Application Features? Site Collection Features?
  3. How to reliably get ViewsLifeTime and ViewsRecent for everything? Is it correct that I always need to include to SortList parameter otherwise the views properties are null?
0

Well this has been quite a ride... Let me answer my own questions:

Answer 1: View events are generated "instantly", though you can't see them right away due to - you guessed it - timer jobs. Now let me explain the flow:

Analytics processing flow

  1. Visitors do something on your website, for example, they view an item. This generates a usage event.
    1. The usage event is recorded in the Event store.
    2. The usage events are sent to the Analytics Processing Component where they are analyzed. The result is sent to the Search index.
    3. When visitors navigate to a page that contains a Recommendations or Popular Items Web Part, a query is automatically issued and sent to the search index.
    4. The query results are returned from the search index and displayed in the Recommendations and Popular Items Web Part on your website.

via SharePoint IT Pro Blog

Answer 2: My question was basically false. Blog post entries are tracked nowhere in SharePoint per default. Why? Blog posts are consumed via the Post.aspx page - this page is different than the URL of the list item (obviously). The problem is that the usage events are tracked based on the URL - since Post.aspx?ID=1 is different than DispForm.aspx?ID=1 the usage events are not correlated. You can't get blog post usage analytics be default 😞
The solution? I added a custom JavaScript to all Post.aspx pages that calls SP.Analytics.AnalyticsUsageEntry.logAnalyticsEvent2 manually via JavaScript with the correct URL and pronto - I have usage events for blog posts.

Answer 3: I haven't a good answer for this. It seems like SortList always needs to include ViewsRecent or ViewsLifeTime otherwise you don't get usage statistics 🤷

A couple of links that explain everything in greater detail:

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.