Forum Discussion

Theodore Tumulty's avatar
Theodore Tumulty
Copper Contributor
Apr 20, 2018

More in-depth reporting on Team sites

Just curious if there is a way to run a more detailed usage report on Team sites. I can only see total site visits and the blue bar graph on most popular documents. The blue bar graph doesn't actually have view numbers, just a bar with no scale. I was hoping to see actual number of views per document. Our IT manager says I can't see this because it is a Team site and not a regular sharepoint site. Is this true?

 

Thanks for the help in advance.

  • You can always run a report against the Office 365 audit log to retrieve FileAccessed events for files in a document library. You'll be able to count the views that way.
    • TonyRedmond's avatar
      TonyRedmond
      MVP

      And here's some PowerShell to report the number of accesses to documents in a particular site over a 3-month period.

       

      $SiteId = "acfe74d8-edfb-436d-924b-e018666605ee"
      $Records = (Search-UnifiedAuditLog -StartDate 1-Feb-2018 -EndDate 1-May-2018 -Operations FileAccessed -ResultSize 2000 -SiteIds $SiteId)
      If ($Records.Count -eq 0) {
         Write-Host "No SharePoint file access records found." }
       Else {
         Write-Host "Processing" $Records.Count " SharePoint file access audit records..."
         $Report = @()
         ForEach ($Rec in $Records) {
            $AuditData = ConvertFrom-Json $Rec.Auditdata
            If ($AuditData.SourceFileName -NotLike "*aspx*" -And $AuditData.SourceFileName -NotLike "*jpg*" ) {
               $ReportLine = [PSCustomObject][Ordered]@{
                 TimeStamp   = $AuditData.CreationTime
                 User        = $Rec.UserIds
                 Action      = $AuditData.Operation
                 Workload    = $AuditData.Workload
                 URL         = $AuditData.SiteUrl
                 Document    = $AuditData.SourceFileName }      
              $Report += $ReportLine }
            }
      }
      
      $GroupData = $Report | Group-Object -Property Document
      $GroupData | Sort Count -Desc | Select Name, Count

      The key thing here is to know the site identifier (GUID) for the site you want to analyze. One way to get this is to run an audit search for FileAccessed events and select one that matches the site to analyze. If you look at the extended audit event properties, you see a site id like the one shown in the code.

       

      After that. it's just a matter of grabbing the audit events, filtering them, and the grouping and reporting the file names. You get something like this:

       

      Name                                                                                                 Count
      ----                                                                                                 -----
      Ch 16 - Office 365 Apps.docx                                                                           167
      Updates to the Fourth Edition.docx                                                                     132
      HoldInfo.Xml                                                                                           130
      Ch 15 - Managing Office 365 Groups.docx                                                                123
      Ch 3 - Office 365 Basic Workloads.docx                                                                  55
      Ch 14 - Office 365 Groups.docx                                                                          49
      Ch 20 - Reporting and Auditing.docx                                                                     46

      The code to analyze audit events is taken from Chapter 20 of Office 365 for IT Pros (https://gum.co/O365IT)

  • Are you aware of the Power BI Adoption Pack? You have there more in deep information about Office 365 workloads and you can also use the underlying model to create your custom reports. Additionally, you can use the Office 365 Reporting API to get more information.
    - https://support.office.com/en-us/article/office-365-adoption-content-pack-77ff780d-ab19-4553-adea-09cb65ad0f1f
    - https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/report

Resources