Get Stream video viewers and views

Within Stream (on SharePoint) it is possible upload, share and manage videos. In this article I will show you how to retrieve analytics via a Power Automate flow for such type of video files.

Inspiration

This question from Tracy_ngu:

I would like to get the views of my videos (as per highlighted below) and add a row into Excel Online. As I understand, the only way is by sending a HTTP request to Sharepoint.

Power Users Community thread: What is the API to get Stream on Sharepoint Video Analytics?.

Stream Analytics

Stream used to be a separate product. However, the new Stream (on SharePoint) hosts and manages the video files on SharePoint Online. The additional benefit of using SharePoint Online is that you are able to use the out of the box analytics features as well.

Below is an example of the File Statistics interface of a single file.

viewers_views

Get itemAnalytics

In our scenario the goal is to retrieve those details via a Power Automate flow. We can use the Get itemAnalytics method from the Graph API.

In a Send an HTTP request to SharePoint action it is possible to use SharePoint REST operations via the Microsoft Graph REST API. As outlined in that document sites and lists are supported endpoints.

With the Get itemAnalytics method you can specify if you want to retrieve allTime analytics or just for the lastSevenDays. I am using the allTime option.

That method will return an access property which contains nested actionCount (Views) and actorCount (Viewers) properties.

Flow Setup

This sample assumes you have already retrieved the siteid, listid and uniqueid of the video file. Have a look at my related articles to find out how to retrieve those values.

streamvideoanalytics

1. Add a Manually trigger a flow action.

manuallytriggeraflow

2. Add a Initialize variable action.

siteid_variable

a. Provide a Name, in this example SiteId
b. Select a Type, String
c. Provide a Value, in this case contoso.sharepoint.com,cb12be95-3f7d-418a-bc6b-a998a72090fd,4dd1a58b-7dc0-4133-9718-3a36d1d79efb

3. Add a second Initialize variable action.

listid_variable

a. Provide a Name, in this example ListId
b. Select a Type, String
c. Provide a Value, in this case 99a3c302-8818-46fb-a1df-8d89d9210200

4. Add a third Initialize variable action.

uniqueid_variable

a. Provide a Name, in this example UniqueId
b. Select a Type, String
c. Provide a Value, in this case dc14e005-c044-4841-8e38-4c11fd51429a

5. Add a Send an HTTP request to SharePoint action.

alltime_actorandactioncount

a. Select your preferred site in the Site Address
b. Use the GET method
c. Use the URI from the code snippet below

d. Use the Headers from the code snippet below

The test results

When you run this flow you should see the same counts in the outputs.

testresult_actoractioncounts

Happy testing!

You may also like...

4 Responses

  1. Josiah says:

    This doc is showing EXACTLY I am trying to do, however there are some steps missing for me at the beginning that are prohibiting me from building it. I followed your links to get the site, list and unique ID’s ,but I can’t even start those because you create variables with items I don’t know how to get. For example: What is the Tenant Root Site, Server Relative URLSite, List Name, Item ID, Library Name, etc….

    Appreciate any help you can give. I’m now to HTTP requests so I apologize for my introductory questions.

  2. Josiah says:

    I’m an idiot….. I just saw the text where you lay all that out…

  3. Eve says:

    I was able to do this and it works great! However, I have several videos in various folders and subfolders that I want to capture the views and viewers for and put this information in a lists for tracking and reporting on. Is that possible?

  4. Dennis says:

    Hi Eve,

    Yes, that should be possible. That either requires looping or you could also use a $batch API request
    https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/make-batch-requests-with-the-rest-apis

    Also have a look at the Get item activity stats by interval method as well. This method might also be useful.
    https://learn.microsoft.com/en-us/graph/api/itemactivitystat-getactivitybyinterval?view=graph-rest-1.0&tabs=http

    Microsoft also keeps adding new usage analytics reports to their services. So also keep an eye out for those on the Roadmap site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.