Is it possible to keep track of visitors to a page based on its address/url?
i) Normally, in PHP, we have session variables/cookies:
ex: $_SESSION['visits']++;
ii) Is there any method to calculate visitors to a particular page, i.e. without having the above code
at each page?
like:
if(page_url == '')
inc++;
els开发者_运维问答e if(page_url == '')
inc2++;
Use an array: isset($visits[$page_url]) ? $visits[$page_url]++ : 1;
. What it does if there if thats a first visit to an url, it assigns a valute to array with a key $page_url. But then you have to store these values somwhere (probably a database). For a database you need to create a database table or even a set of tables.
But why do it yourself if there is already Google analytics that calculates visits, unique visits, browser statistics, shows where user has clicked on your page, where user came from and much much more?
精彩评论