Thursday, June 5, 2014

Hiding 'Top Visitors' Web Analytics report from users in SharePoint 2010




Addd  the Java script below the tag line in report page under layout 

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\WebAnalytics\reports.aspx

  asp:Content ID="Content1" runat="server" ContentPlaceHolderID="PlaceHolderLeftNavBar" 



</SharePoint:VersionedPlaceHolder>

      <script type="text/javascript">
if (window.location.href.indexOf("/_layouts/WebAnalytics/Report.aspx?t=TopVisitorsReport") != -1)
{
alert ("This function is not allowed");

url = window.location.href;
url = url.replace(/TopVisitorsReport/g, "SummaryReport");

window.location.href = url;
}

        var cc = document.getElementsByTagName("a");

        for (var i = 0; i < cc.length; i++)
{
        var link = cc[i];


  if (link.href.indexOf("/_layouts/WebAnalytics/Report.aspx?t=TopVisitorsReport") != -1)
           //link.parentNode.style.display = "none";
                    link.parentNode.removeChild(link);
               
        }
     </script>

</asp:Content>