开发者

Page counter based on address

开发者 https://www.devze.com 2023-03-19 19:38 出处:网络
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:

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?

Page counter based on address

0

精彩评论

暂无评论...
验证码 换一张
取 消