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
Hari@RockzsHari@Rockzs 

How to get Number of pageviews?

Hi,

 

                     i have vfpage,in my organisation i have 40 users.Now my requirement is how to get number times that vfpage viewed by users ,like in our community number of views to the question in the same page.

 

 

Canu please help me

 

Thank u

Hari@RockZ

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

Ok,

I understand your requirement as follow.

 

You need to track User A views Page P , N times and User B views Page P, K times 

and You need to Show this Numbers on VF page.

List<Cookie> lstcookie=new List<Cookie>();    
Map<string, System.Cookie> mpCookie=Apexpages.currentPage().getCookies(); lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); } } else { bIsFirstClick=true; lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); } } } else
{ bIsFirstClick=true; lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); }

 

 

 

you can use Apex Cookies, by using Apex Cookies you can build your own analytic framework.

 

your cookie will be map of  USERID as Key  Number_Of_PageViews as Value

 

 

here is some sample code for cookies

 

 

All Answers

Ryan-GuestRyan-Guest

I'd suggest using Google Analytics http://www.google.com/analytics/

 

You put a javascript snippet on each page and you can get analytics about who is viewing your page.

 

You could also roll your own analytics framework.

Hari@RockzsHari@Rockzs

ok,thank u friend,

 

            but i am not getting how i can use that in apex coding,can u explain in brief how to get number of page views through apex coding and i have shown that pageviews number in vfpage

 

 

Can u please help me

 

 

Hari@RockZ 

b-Forceb-Force

Ok,

I understand your requirement as follow.

 

You need to track User A views Page P , N times and User B views Page P, K times 

and You need to Show this Numbers on VF page.

List<Cookie> lstcookie=new List<Cookie>();    
Map<string, System.Cookie> mpCookie=Apexpages.currentPage().getCookies(); lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); } } else { bIsFirstClick=true; lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); } } } else
{ bIsFirstClick=true; lstcookie.add(new Cookie('lastLoginStamp',LatestValue,null,-1,false)); pr.setCookies(lstcookie); }

 

 

 

you can use Apex Cookies, by using Apex Cookies you can build your own analytic framework.

 

your cookie will be map of  USERID as Key  Number_Of_PageViews as Value

 

 

here is some sample code for cookies

 

 

This was selected as the best answer
Hari@RockzsHari@Rockzs

Hi,

Thank u  Bala for guiding us with your Great Experience&Knowledge,

 

I have another scenario that,

 

                       Can u give any help regarding Content search in Documents.

 

Scenario:

 

           like google search if u enter any key word in textbox,then search will be done in documents and the documents which contains that keyword will display in VFpage

 

 

Hari@RockZ

b-Forceb-Force

There are some limitations on content search, as we cant use document content in where clause.

 

If we SOQL more document/attachment records , then we frequently cross the apex view state limit.

 

hense we cant implement similar to google,

But we can process the document records in CHUNCK OF 1000 or more***  records by prcise apex code.

 

Hope it will help you,

 

Cheers,

Bala

 

Hari@RockzsHari@Rockzs

Bala Thank for Reply,

 

can u provide any apexcode snippet which will helps for me regarding content search.

 

 

SFDCBlueFish