1

I want to add the number of site views to Home page. This number displays on the page of site content by default.

enter image description here

I use iframe to add this part to home page. But the page which in the iframe always has scroll. (Not scroll of iframe) How could I hide this scroll of page ? Or there are other ways to put this number to home page ?

    <div style="border: none; overflow: hidden;max-width: 420px;">
<iframe id="SiteVisits" scrolling="no"
  src="https://domain/_layouts/15/viewlsts.aspx?view=14" style="border: 0px none; margin-left: -50px; height: 796px; margin-top: -330px; width: 340px;">
    </iframe>
    </div>
2

Just for site visits count if you put site contents page in an iframe will not be an ideal solution. It would be better to create a component using a rest api call.

Here is the query to get the information required for site visits.

_spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='*'&querytemplate='(WebId:" + _spPageContextInfo.webId + " OR WebId:" + webId with our braces + ") AND (contentclass:STS_Site OR contentclass:STS_Web)'&rowlimit=1&bypassresulttypes=false&selectproperties='Title,Path,Filename,Created,LastModifiedTime,LinkingUrl,ParentLink,WebId,UniqueID,ViewsLifeTime,ViewsLifeTimeUniqueUsers,ViewsRecent,ViewsRecentUniqueUsers,ViewsLastMonths1,ViewsLastMonths1Unique,ViewsLast7Days,ViewsLast6Days,ViewsLast5Days,ViewsLast4Days,ViewsLast3Days,ViewsLast2Days,ViewsLast1Days,ViewsLast7DaysUniqueUsers,ViewsLast6DaysUniqueUsers,ViewsLast5DaysUniqueUsers,ViewsLast4DaysUniqueUsers,ViewsLast3DaysUniqueUsers,ViewsLast2DaysUniqueUsers,ViewsLast1DaysUniqueUsers'&SourceId='8413cd39-2156-4e00-b54d-11efd9abdb89'"

The example should be as follows

https://tenant.sharepoint.com/_api/search/query?querytext='*'&querytemplate='(WebId:{0aec79ea-0f5c-4f2f-a1ca-74b3af08bcad} OR WebId:0aec79ea-0f5c-4f2f-a1ca-74b3af08bcad) AND (contentclass:STS_Site OR contentclass:STS_Web)'&rowlimit=1&bypassresulttypes=false&selectproperties='Title,Path,Filename,Created,LastModifiedTime,LinkingUrl,ParentLink,WebId,UniqueID,ViewsLifeTime,ViewsLifeTimeUniqueUsers,ViewsRecent,ViewsRecentUniqueUsers,ViewsLastMonths1,ViewsLastMonths1Unique,ViewsLast7Days,ViewsLast6Days,ViewsLast5Days,ViewsLast4Days,ViewsLast3Days,ViewsLast2Days,ViewsLast1Days,ViewsLast7DaysUniqueUsers,ViewsLast6DaysUniqueUsers,ViewsLast5DaysUniqueUsers,ViewsLast4DaysUniqueUsers,ViewsLast3DaysUniqueUsers,ViewsLast2DaysUniqueUsers,ViewsLast1DaysUniqueUsers'&SourceId='8413cd39-2156-4e00-b54d-11efd9abdb89'

The sum of visitors count is equal to visits count

var viewsCount = ViewsLast7Days + ViewsLast6Days + ViewsLast5Days + ViewsLast4Days + ViewsLast3Days + ViewsLast2Days + ViewsLast1Days

You can create a complete component using JavaScript/jQuery, AJAX, HTML, and CSS.

  • all those values are null for me, what could be the reason? – Vignesh Subramanian Jul 26 '18 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.