Website Analytics For Modern SharePoint Site

New Contributor

I am trying to create a simple webpart that can be added to the bottom of a page and will insert the HTML <script> tag to add analytics to a page. I don't want to implement it across the entire tenant or even across all pages of a site. I want to control which specific pages are tracked. I created a simple SPFX webpart that inserts the <script> tag into the page. When I check the page source code, the <script> tag is there but it doesn't seem to be firing. The analytics platform isn't showing results and it isn't registering that the JS has been run. I verified with the SP admin that users are allowed to run custom scripts on self-service sites. Any ideas why this is happening?

4 Replies
Which Analytics Platform are you using? By the way, I recommend you to create and deploy a SPFx Extension in your site instead of a Web Part

@Juan Carlos González Martín Siteimprove. I will look into the SPFX Extension. I haven't done that before.

And thank you for responding.
Why would you recommend an SPFx Extension instead of a webpart?