function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChinnoduChinnodu 

how we can count the number of a specific visualforce page opened by a user.

Hi Team,

how we can count the number of a specific visualforce page opened by a user. please provide the example code .

Thanks,
Chinnodu
Jakub Kołodziej 7Jakub Kołodziej 7
Create an object, VF_Tracking__c, that has a lookup(User) User__c, text(255) VF_Page_Visited__c

In your Visualforce controller, create a pageReference method to track who visits the page.

Controller code:
public class myController{
public pageReference track(){        VF_Tracking__c newTracking = new VF_Tracking__c(User__c=UserInfo.getUserId(),VF_Page_Visited__c='myVFPage');
 insert newTracking;
return null;}
}


VF:
<apex:page action="{!track}"></apex:page>


Or use RemoteAction to increase performance, below is js remoting example:
JS Remote (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_js_remoting_example.htm)