The best way that i know to do it is using Microsoft Pureview Portal;
Steps to Retrieve the information
- Verify That Auditing Is Enabled
- Sign in to the Microsoft Purview Compliance Portal: Navigate to the Microsoft Purview compliance portal.
- Check Audit Settings: Go to Audit and confirm that auditing is enabled. (In most Office 365 tenants, this is enabled by default.)
- Run an Audit Log Search
- Access the Audit Search Tool: In the compliance portal, click on Audit.
- Set Up Your Query:
- Date Range: Choose your specific period of interest.
- Activities: Select actions relevant to site access—this might include events such as “Viewed page,” “File accessed,” or any activity that indicates a user visited your SharePoint site.
- Specific Site Filtering: If needed, use the “File, folder, or site” field to limit results to your intranet site URL.
- Execute the Query: Run the query to retrieve the user activity data.
- Export the Results
- Download the Data: Once the query completes, export the results to a CSV file.
- Extract Visitor Information: Open the CSV file in Excel (or process it via PowerShell or another scripting tool) to extract unique user identifiers—typically you'll have columns for the user's name and their email address.
If you found it helpful, could you kindly click the “Accept Answer and upvote” on the post.
If you have any further queries, please let us know we are glad to help you.