We are launching a big SharePoint Online project for 15000+ users, and the project owners want to know how end-users are using and behaving inside the SharePoint Online.

Are there OOTB features for these admins to see: Analytics, Usage, Statistics and Reports?

Of course, I am aware of the new-experience of the Site Contents page, But, Are there more advanced reporting capabilities that are displayed for Admins or site owners?

Please, Share your thoughts and suggestions to meet such requirements !

1 Answer 1


We are using a CustomAction comprised of Google Analytics code. All of the auditing and compliance functions are lacking to track basic page views easily. Adding a user dimension allows us to dive a little deeper into who is viewing what.

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-123456789-0', 'auto');
  ga('send', 'pageview');


This JS file is stored in the site assets library. Then using PowerShell and CSOM, we add this file as a CustomAction to the site.

function New-CustomAction{
            Creates a new custom action on the spicifed address
            Creates a new custom action on the spicifed address
        .PARAMETER Url
            The Url to add a custom action to
        .PARAMETER ActionType
            Site or web UserCustomActions to find
        .PARAMETER Title
            The title of the CustomAction
        .PARAMETER ScriptSrc
            The full URL to the path of the file to attach
        .PARAMETER Sequence
            The sequence number in which this is to be executed, lower numbers get executed first
        .PARAMETER Description
            A description of the custom action
            Creates a UserCustomAction with the specified parameters
            New-CustomAction -Url "https://tenant.sharepoint.com/teams/eric/subsite" -ActionType "Web" -Title "Acknowledge Script" -ScriptSrc "https://tenant.sharepoint.com/teams/eric/subsite/SiteAssets/testscript.js" -Sequence 0

        [Parameter(Mandatory=$true,HelpMessage="The URL of the site or web")][ValidateNotNull()]
        [Parameter(Mandatory=$true,HelpMessage="The action type scope")][ValidateNotNull()]
        [Parameter(Mandatory=$true,HelpMessage="The title of the CustomAction")][ValidateNotNull()]
        [Parameter(Mandatory=$true,HelpMessage="The full URL to the path of the file to attach")][ValidateNotNull()]
        [Parameter(Mandatory=$true,HelpMessage="The sequence number in which this is to be executed")][ValidateNotNull()]
        [Parameter(Mandatory=$false,HelpMessage="A description of the custom action")]
        $context = New-Object Microsoft.SharePoint.Client.ClientContext($Url) 
        $context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName, $credential.Password)

        if($ActionType -eq "Site"){
            $site = $context.Site
            $site = $context.Web
        $action = $site.UserCustomActions.Add()
        $action.Location = "ScriptLink"
        $action.ScriptSrc = $ScriptSrc
        $action.Title = $Title
        $action.Sequence = $Sequence
            $action.Description = $Description
            write-host -ForegroundColor Green "New UserCustomAction created successfully!" 
            Write-Host -ForegroundColor Red $_.Exception.Message



New-CustomAction -Url "https://tenant.sharepoint.com/teams/eric" -ActionType "Site" -Title "Analytics Code" -ScriptSrc "https://tenant.sharepoint.com/teams/eric/subsite/SiteAssets/ga.js" -Sequence 0

This "Staples" the JS file to run on every page load in your site collection, reporting back to Google Analytics which you can the slice and dice as you want, or pull it into Power BI.

  • I love the idea of using Google Analytics, But, I am not sure I understood your text about "using a CustomAction comprised of Google Analytics code." Could you please elaborate a bit more on how your code snippet adds data into google analytics table ?
    – Alex
    Jun 24, 2016 at 22:53
  • Let me dig up my code, and I'll refine this answer Jun 25, 2016 at 0:51
  • Please do Eric, Thank you very much and I look forward to hearing from you soon !
    – Alex
    Jun 25, 2016 at 21:07
  • @Alex updated answer Jun 27, 2016 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.