How to Add Microsoft Clarity Projects Programmatically with PowerShell
Question details
The user wants to automate the creation of Microsoft Clarity projects for approximately 150 SharePoint site collections using a PowerShell-based solution.

- Product
- Microsoft Clarity / SharePoint
- Device & OS
- not provided
- Scenario
- Deploying analytics tracking across a large number of SharePoint site collections without manually creating a new project for each one.
- Observed behavior
- Standard SharePoint PowerShell administration modules do not include cmdlets for Microsoft Clarity, requiring a custom API integration approach.
Ensure you have global administrative access to your SharePoint environment and have registered a primary Microsoft Clarity account before attempting API-level automation.
Consult the Microsoft Clarity GitHub Community for API Access
Since Microsoft Clarity provisioning requires product-specific APIs not included in standard SharePoint PowerShell modules, consulting the official developer community is the required path.
Microsoft Clarity does not natively provide standard PowerShell cmdlets (like PnP PowerShell) for bulk project creation out of the box. Automating the creation of projects for 150+ site collections typically requires interacting directly with Clarity REST APIs.
Because this involves customized API scripting rather than built-in SharePoint Online administration, official documentation on standard community forums is limited. The Clarity engineering team provides direct guidance for these advanced scenarios via GitHub.
Go to the Microsoft Clarity GitHub issues page at https://github.com/microsoft/clarity/issues.
Use the search bar to look for existing discussions related to 'PowerShell automation', 'bulk creation', or 'API project creation'.
If no existing documentation fits your needs, open a new issue detailing your requirement to provision projects programmatically for 150 SharePoint site collections.
Once the Clarity engineers provide the supported REST API endpoints, use the PowerShell `Invoke-RestMethod` cmdlet to loop through your site collections and trigger the automated project creation.

Looking for a Lightweight Productivity Suite? Try WPS Office
While you manage complex SharePoint deployments and custom PowerShell scripts, you might also need a reliable, everyday office suite. WPS Office is a highly compatible, free, and lightweight alternative to Microsoft Office that handles your documents, spreadsheets, and presentations seamlessly.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation file for your operating system.
- 2. Install WPS Office: Run the downloaded executable and follow the quick on-screen instructions to complete the setup.
- 3. Open Your Documents: Launch WPS Office to instantly open, edit, and save your existing Microsoft Office files without formatting loss.

Frequently Asked Questions
Can I use standard PnP PowerShell to create Microsoft Clarity projects?
No. PnP PowerShell is designed for SharePoint administration and does not natively include cmdlets for Microsoft Clarity project creation. You must use `Invoke-RestMethod` to interact with Clarity APIs.
Where can I find the official API documentation for Microsoft Clarity?
Microsoft Clarity's programmatic features are best supported directly by their engineering team. It is highly recommended to reach out via their official GitHub repository (microsoft/clarity) for the most current API guidance.
How do I deploy the Clarity tracking code to SharePoint after creating the project?
Once a project is successfully created and a tracking ID is generated, you can deploy the Clarity tracking script across your modern SharePoint sites using SharePoint Framework (SPFx) Application Customizers.




