The “correct” answer depends on the situation; First of all, the most desirable statistics and the availability of resources for their collection and processing: for example:
Server side
Raw Web Server Logs
All web servers have the ability to register requests. The problem with them is that it takes a lot of processing to get meaningful data, and for your example scenario, they won’t write specific application data; for example, whether the request was associated with a registered user.
This option will not work for what interests you.
File Based Application Logs
The programmer can apply a special code to the application to write the material that interests you the most into a log file. This is similar to a web server log; except that he may be aware of the application and record things like the participant making the request.
Programmers may also need to create scripts that extract material from these magazines that you are most interested in. This setting may be appropriate for a high traffic site with lots of disk space and system administrators who know how to ensure that the logs are rotated and clipped from production servers before bad things happen.
Database-Based Application Logs
An application programmer can write custom code for an application that writes each request to a database. This makes it easy to run reports and makes data instantly available. This solution imposes additional system overhead during each request, which is better suited for smaller sections of traffic or scenarios where data is highly valued.
Client side
Javascript callback
This applies to the above parameters. Google analytics does this.
Each page contains some javascript code that tells the client to report to the web server so that the page is viewed. Data can be written to a database or written to a file.
It has a strong advantage in improving the accuracy of scenarios when impressions are lost due to intensive caching / proxy between the client and server.
Cookies
Each time a request is received from a person who does not present a cookie, you assume that they are new and the record that was deleted as “anonymous” and return a uniquely identifying cookie after logging in. It depends on your statement about how accurately this is confirmed. Some applications cannot be cached, so they will be fairly accurate; others (high traffic) encourage caching, which reduces accuracy. Obviously, this is not so much until they are re-authenticated each time the browsers / locations switch.
What are you most interested in?
Then the question arises about which statistics are important to you. For example, in some situations you want to know:
- how many times the page was viewed, period,
- how many times a page was viewed by a known user
- how many of your famous users viewed a particular page
From here, you usually want to break it down into time periods to see the trend. Respectively:
- Are we getting more views from random people?
- or do we get more views from registered users?
- or has almost everyone who sees that the page now sees it?
So, back to your question: best practice for "the number of prints when the user goes to the page"?
It depends on your application.
I assume that your best bet is to use a database-enabled application that records what is most interesting to your application and uses cookies to track member sessions.