Skip to content

Unable to get analytics for multiple pages in Graph #11099

Open

Description

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint REST API

Developer environment

None

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

No response

Describe the bug / error

What I'm doing

I'm reading view counts for the pages in a Site Pages library through Microsoft Graph, and I'm trying to get them for all items in one request instead of one request per page.

Steps to reproduce

  1. Pick a Site Pages library where some pages have views.

  2. Confirm a page has views with the per-item request:

    GET /sites/{siteId}/lists/{listId}/items/{itemId}/analytics/allTime
    

    This returns the view count as expected.

  3. Request the same data for all items:

    GET /sites/{siteId}/lists/{listId}/items?$expand=analytics($expand=allTime)
    

Observed

The request returns 200, but every item has:

"analytics": { "allTime": null, "lastSevenDays": null }

This includes the pages that return a view count in step 2.

Expected

Either the same values as the per-item request, or an error saying this $expand isn't supported on a collection.

Question

Is the null result the intended behaviour? If $expand=analytics isn't supported on a list's items, is that documented anywhere? I couldn't find it.

Steps to reproduce

  1. Pick a SharePoint Online site with a Site Pages library where at least one page has been viewed.

  2. Get the site ID:

    GET https://graph.microsoft.com/v1.0/sites/{hostname}:/sites/{sitePath}
    
  3. Get the ID of the Site Pages list:

    GET https://graph.microsoft.com/v1.0/sites/{siteId}/lists?$filter=displayName eq 'Site Pages'
    
  4. List the pages and note the ID of one that has views:

    GET https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items
    
  5. Request the analytics for that one page:

    GET https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items/{itemId}/analytics/allTime
    

    The response has the view count in access.actionCount.

  6. Request the analytics for all items in the list:

    GET https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items?$expand=analytics($expand=allTime)
    
  7. Find the page from step 5 in the response. It has "analytics": { "allTime": null, "lastSevenDays": null }, as does every other item.

Expected behavior

Each item in the response carries the same allTime data that the per-item request returns for that item. For a page with views, that would look like:

"analytics": {
  "allTime": {
    "access": { "actionCount": 123, "actorCount": 45 }
  }
}

So for any item, analytics.allTime from

GET /sites/{siteId}/lists/{listId}/items?$expand=analytics($expand=allTime)

matches the response of

GET /sites/{siteId}/lists/{listId}/items/{itemId}/analytics/allTime

If expanding analytics on a collection of list items isn't supported, I'd expect a 400 error that says so, not a 200 response with allTime: null for pages that have views.

Activity

  1. added
    type:bug-suspected
    on Nov 19, 2026
  2. m365-agent-toolkit-assistant commented on Nov 19, 2026

    @m365-agent-toolkit-assistant

    👋 Hi Alex Accelerator 365 (@AlexAccelerator),

    Thank you for reporting this issue. Here is an AI-generated initial response:

    Classification: By design — inline page view counts are a known API gap, although the 200 response with null analytics has not been confirmed as intentional.

    • You can retrieve allTime for an individual item. A Microsoft contributor confirmed in a related issue that view counts currently cannot be included inline with Graph page/list-item responses.
    • The Graph list-items documentation permits $expand but does not explicitly explain the null result for analytics.

    What to do now:

    1. Keep using the per-item analytics endpoint; use Graph $batch to reduce round trips. Each request still counts toward throttling.
    2. If indexed results meet your freshness needs, evaluate SharePoint Search REST separately; it is not a substitute for live analytics.
    3. Report the misleading 200/null response as a documentation or API-behavior gap, with the paired responses and request IDs.

    Useful links:


    Note: AI-generated guidance may be incomplete or incorrect. Please verify suggestions before applying them.

  3. added
    area:csom/rest/api
    sharepoint-developer-support
    on Nov 20, 2026
  4. Ashlesha-MSFT commented on Nov 20, 2026

    @Ashlesha-MSFT
    Contributor

    Hi Alex Accelerator 365 (@AlexAccelerator),

    Thank you for providing the paired requests and detailed reproduction steps.

    The list-items documentation supports $expand, and the listItem resource includes an analytics relationship. However, we have not identified documentation explicitly supporting:

    or explaining the 200 OK/null response for that query. The itemAnalytics documentation lists allTime and lastSevenDays as properties; it does not establish support for the nested expansion shown here.

    Therefore, the current evidence is insufficient to confirm this behavior as by design . The related Microsoft response in #10867 confirms the current inline-analytics capability gap, but does not resolve the response-behavior question raised in this issue.

    For now, please continue using the documented per-item analytics endpoint. Clarification from the API owners would be needed to determine whether the collection request should reject the query or return populated analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AI-generated responsearea:csom/rest/apisharepoint-developer-supporttype:bug-suspected

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions