Answer the question
In order to leave comments, you need to log in
How can I find out the total number of visits to my site?
I want to display information about how many times my site was visited, tell me how to do this, register a regular table in the database and store this information, if so, how is it better to make a table, or how can it be done differently?
I use postgresql
Answer the question
In order to leave comments, you need to log in
an easy way to put a counter from google.
Another option is to insert a script that reads everything possible from the client, generates an address, adds a random entry and queries your server
If we take exactly the visit without user identification, then the usual counter will come down.
If it is by users, then we determine the parameters (IP address, browser User-Agent, session cookies). We create a table for them and when visiting the site we add an entry to this table if there is no such entry. And the COUNT of all entries will be the number of visitors. But it will be easier and better to add ready-made metrics (Google AdWords, Yandex Metrica, etc.).
UPDATE metrics SET counter = counter + 1
Do not forget to answer the question - what does a visitor mean (for example, someone took a link with a picture from a site and placed it on another site in the img tag, is everyone who sees this picture a visitor?), should the old user re-enter as a new one or not? how long to store information?
If you are not on someone else's hosting, you have a web server and its logs, all the information is
parsed there with a simple cron script, what exactly and how to count depends on your Wishlist, this is exactly what they did and still do.
Third-party scripts from advertising networks will give ready-made information, but do not forget, in this way you give your users (their private information) 'to be torn apart' by them...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question