Click here to Skip to main content
15,918,268 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do i count no of views in every page in my website i know how to count total no of visitors but i'm unable to count no of views for separate page

What I have tried:

i tried with using session with global.asax and count no of view and i used xml for counting no. of views but i think its not good to make xml page for every page in website
Posted
Updated 15-Aug-16 8:04am

I know you say you don;t want to use a third party service, but this is exactly what services like Google Analytics are made for. They not only get you page count, but load speed, browser technology, visitor location, and a whole raft of other useful data. There's also likely to be a plugin or premade script available to add the code to your site without you having to reinvent the wheel.
 
Share this answer
 
html? php?

If your pages are php, for example, as each page is rendered it can include a call to a function to increment the count in a database. You don't even need to name the page as the page's info can be gotten from $_SERVER[] data, which can be used to find the entry in the database for update.

If well done, the script could add entries for you so it becomes self-maintaining as you add new pages (with the basic generic counting script).

 
Share this answer
 
Comments
rahulkumar013 15-Aug-16 13:35pm    
it's Asp.net sir
IF I'm using xml it works fine for total no of visitors but i have to count no of views for every single page i dont want to use third party services there are so many free services available i dont need them
W Balboos, GHB 15-Aug-16 13:41pm    
I don't use ASP.NET at all, but, in principal, it should be the same.

You create a function that's executed (in the header, if possible) that updates a record in the database. If ASP.NET is capable, have it ask the page for its own name and it can use that to insert/update records with the count.

Using this concept, you only need to make the table and wait - the entries will be put in for you and counted.

You check for the existence of the page-name entry in your table. If it finds it, increment count via an UPDATE. If it doesn't find it, INSERT a new record with count = 1;

The only labor would be inserting the function call into each of the pages you wish to monitor. Your editor may allow you to do all the pages at once if you ask it correctly (don't do this wrong!!!).
rahulkumar013 16-Aug-16 6:35am    
Is is necessary to record the count in database for every page if i'm using more than 100 pages then i have to make 100 tabels in my database
W Balboos, GHB 16-Aug-16 6:42am    
No - let the code you write do the work for you! PHP lets me get the name of the page I'm requesting when it's requested for use on the server side even before the page is sent to the client. You don't have to customize the call for each page - the page, itself, does that for you.

1 - Test for the existence of the page in your table (by name, I suppose).*
2 - If the page exists then increment the counter
3 - If the page does not exist then add the page to your list and set the counter to '1'.

Note that this will take care of itself whenever you add a new page - automatically - with no effort on your part other than the function call at the top of each page. You do not have to add a single entry.


* SQL has an existence test. Alternative, you can request the record count for a given page (by name). If the count is 0, add the page, otherwise, increment its counter.
rahulkumar013 16-Aug-16 6:36am    
i need something which i can use in every page to record every page views i dont know how i can do it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900