Using SharePoint API or Graph API how can I extract who visited a SharePoint site page and when?

Mr Hussain 0 Reputation points
2024-04-24T14:29:33.2766667+00:00

I've come across a few articles which talk about extracting the SharePoint site usage information using the relevant APIs.
So my problem is that the API's I see do not give the required level of granularity I need to be able to create useful report, I'd like to know at the user level how visited the site, when and for how long, this data must exist in SharePoint as I can see it in the Site Usage page hosted on their website.
GET https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D7') Aggregates and so does the one below.

Any ideas where I can find the info?

GET https://contoso.sharepoint.com/sites/{SiteName}/_api/v2.1/sites/contoso.sharepoint.com,{SiteGUID},{webGUID}/lists/%7B{SitePageGUID}%7D/items/{SitePageUniqueId(GUID)}/driveItem?$select=id,analytics&$expand=analytics($expand=allTime)
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,645 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,682 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Haoyan Xue_MSFT 19,871 Reputation points Microsoft Vendor
    2024-04-25T09:03:50.98+00:00

    Hi @Mr Hussain ,

    Thank you for posting in this community.

    After my internal and external searches and research, unfortunately, there is currently no function or method for obtaining SharePoint site page logs through SharePoint API (PowerShell etc.) or Graph API.

    Maybe you can view some information in the page in the UI interface, but it will not be specific to someone at a certain time.

    1.Page Analytics: View usage data for SharePoint pages and news

    236370-microsoftteams-image-4.png

    2.Open Site Settings->Site Actions->Manage site features->Active SharePoint Viewers: Display to site members the names of people who viewed files or pages on their site

    236379-image.png

    Hover over the file to see viewers. Click on view counts to see file statistics.

    236380-image.png

    236330-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.