SharePoint Document Issues

How to Retrieve SharePoint Site Usage Statistics Programmatically

Khadija KhanKhadija Khan Oct 20, 2026 869 views

Question details

The user is attempting to retrieve SharePoint site usage statistics using PowerShell, but the relevant search properties fail to output actual data.

How to Retrieve SharePoint Site Usage Statistics Programmatically
Product
Microsoft SharePoint
Device & OS
not provided
Scenario
Using PowerShell and SharePoint Search properties to programmatically pull usage statistics and unique user views.
Observed behavior
Search properties such as ViewsLifeTime, ViewsLifeTimeUniqueUsers, and ViewsRecent return zero. The built-in analytics page only provides limited data for popular documents from the previous seven days.
Before you start

Ensure you have the appropriate SharePoint administrator permissions and the latest version of the SharePoint Online Management Shell installed before executing administrative scripts.

Solution 1Recommended

Consult the Microsoft Q&A Community for PowerShell Scripting

Because programmatic reporting involves advanced PowerShell and SharePoint Search customization, escalating the issue to specialized Microsoft developers is the most effective approach.

SharePoint APIs and Search properties undergo frequent updates, which can cause scripts relying on properties like ViewsLifeTime to unexpectedly return zero. Expert guidance from the Microsoft community helps identify deprecated APIs or missing search schema mappings.

1
Navigate to Microsoft Q&A

Open your web browser and go to the official Microsoft Q&A platform at learn.microsoft.com/en-us/answers.

2
Filter by SharePoint Tags

Use the search bar to locate and select the 'SharePoint' or 'SharePoint Development' tags to ensure your query reaches the right experts.

3
Post Your Script and Query

Submit a detailed question. Include your current PowerShell script and specify that properties like ViewsLifeTime and ViewsRecentUniqueUsers are returning zero despite site activity.

Consult the Microsoft Q&A Community for PowerShell Scripting
Provide Context: When posting in the community, explicitly mention whether you are using SharePoint Online or SharePoint Server (on-premises), as the programmatic solutions differ significantly.
Free Microsoft Office alternative

Manage Your Documents Seamlessly with WPS Office

While SharePoint handles complex site analytics and deployments, you may need a reliable, lightweight suite for creating and editing your reports locally. WPS Office offers excellent compatibility with Microsoft formats without the heavy enterprise overhead.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
  2. 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to install the suite.
  3. 3. Open Microsoft Documents: Launch WPS Office and directly open your downloaded SharePoint documents (.docx, .xlsx, .pptx) with zero formatting loss.
Fully compatible with Microsoft Word, Excel, and PowerPoint document formats.Free, lightweight suite that installs rapidly and uses minimal system resources.Built-in PDF editing and cloud syncing for efficient document management.Familiar user interface that requires no learning curve for Microsoft Office users.
microsoft office alternative - wps office

Frequently Asked Questions

Why do SharePoint ViewsLifeTime properties return 0 in PowerShell?

This commonly occurs if the SharePoint search schema has not been crawled recently, if the managed properties are not properly mapped to the crawled properties, or if the specific tracking APIs have been updated or restricted in SharePoint Online.

How far back does the default SharePoint Analytics page track data?

The standard built-in site usage page focuses on recent activity and popular documents, typically displaying data limited to the past 7, 30, or 90 days depending on the specific metric being viewed.

Can I use Microsoft Graph API instead of PowerShell for SharePoint statistics?

Yes. Microsoft Graph API is currently the modern, recommended approach for programmatic access to Microsoft 365 data, offering more robust endpoints for retrieving detailed site analytics and usage reports.