Forum Discussion

Rock67's avatar
Rock67
Copper Contributor
Aug 16, 2022

Website Analytics For Modern SharePoint Site

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?

5 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
    • Rock67's avatar
      Rock67
      Copper Contributor
      Why would you recommend an SPFx Extension instead of a webpart?
      • dc365's avatar
        dc365
        Copper Contributor

        Rock67 

        It's been a while since I saw the help article for this...but Microsoft's recommendation is to use a SPFx to roll out third party JS to your SharePoint site instead of using a webpart. I don't recall the rationale but I *think* it's related to avoiding permissions issues, and "forgetting" to add the webpart to new content.

         

        If you're still looking for a solution, our https://analytics.angelfishstats.com/solutions/sharepoint-web-analytics/ can use either a SPFx or Audit Data to create reports.

    • Rock67's avatar
      Rock67
      Copper Contributor
      And thank you for responding.

Resources