SharePoint Newsfeed Insights

Newsfeed InsightsOne of my clients who is using SharePoint 2013 Sitefeeds extensively in his new social intranet asked me to build ‘something’ to get some insights out of the Social feeds.
So I went and build a little demonstration just to get the following insights out of a SharePoint Site Newsfeed.

  • total number of posts
  • total number of replies
  • total number of likes

I wrote the following peace of JavaScript code to get to the JSON response of a Newsfeed. From there it is just a matter of digging through the structure of the data object.

Here are a couple of examples on what to find were in the JSON Response

Total number of posts
data.d.SocialFeed.Threads.results.length

number of replies of a single post
data.d.SocialFeed.Threads.results[0].TotalReplyCount

number of likes of a single post
data.d.SocialFeed.Threads.results[0].RootPost.LikerInfo.TotalCount

number of likes of a single reply of a post
data.d.SocialFeed.Threads.results[0].Replies.results[0].LikerInfo.TotalCount

Here is the complete JavaScript code of my demo. You can use it in SharePoint WebParts, Add-Ins, Apps, or just put the js file in the Site Assets library and use it in a CEWP (Content Editor Web Part)

There is also a really good MSDN documentation on social feeds in SharePoint I want to share with you. https://msdn.microsoft.com/en-us/library/office/dn155789.aspx

UPDATE:

I updated the script to be able to get more than the default 20 threads.
You can use the ‘MaxThreadCount’ Property of the feed to get more threads. I set it in the example to feed(MaxThreadCount=10000) to get up to 10000 threads back. A thread is a post in the newsfeed. This does not count for Replies.