Document Library Settings> Information Management Policy Settings> definition Policy> OK> enable review. If you need to click the number of times on the page, you can customize a field for statistics, custom fields are available in many places. I won't talk about it anymore. I used Audit to count the number of clicks on the entire website. I have mentioned the code 07 added to SPD on the Internet, I have never used 07, and I don't know how to fix it. In addition, many big brothers say that method is no longer usable. So I found Audit as prompted.
Because my pages are all publishing pages, you can imagine that I have all "pages" under the document library. First, I open the tracking record through the following code:
Using (SPSite site = new SPSite ("http: // sps2010 "))
{
SPList list = site. RootWeb. Lists ["page"];
List. Audit. AuditFlags = SPAuditMaskType. View;
List. Audit. Update ();
}
Of course, we can also enable it through the UI:
Document Library Settings> Information Management Policy Settings> definition Policy> OK> enable review
Then I use the following code for statistics:
Using (SPSite site = new SPSite ("http: // sps2010 "))
{
SPList list = site. RootWeb. Lists ["page"];
SPAuditQuery wssQuery = new SPAuditQuery (site );
SPAuditEntryCollection auditCol = list. Audit. GetEntries (wssQuery );
Int I = 1;
Foreach (SPAuditEntry item in auditCol)
{
Console. WriteLine (item. ItemType + "--" + I );
I ++;
}
}
Finally, you can calculate the number of times in the List based on item. ItemType.