Re: Keep track of page-access [message #172898 is a reply to message #172884] |
Fri, 11 March 2011 10:33 |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma:
|
Senior Member |
|
|
El 11/03/2011 19:26, sl@exabyte escribió/wrote:
> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.
>
> Any comment ? Thanks.
The client-side approach you suggest is nothing particularly rare (there
are many site stat services out there that use it, including Google
Analytics), although I'm not sure about why you plan to use AJAX (what
kind of updated information do you want to display in the page once it
has loaded?). However, the purpose of JavaScript-based tracking is
basically to collect information about your users (operating system,
desktop size, installed plug-ins...); for a simple counter it's just
overkill. A simple <img> to a PHP script that serves a 1x1 transparent
GIF can do the same and drops the requirement of using a JavaScript
enabled browser.
In any case, client-side tracking will only provide an approximation
since it'll be leaving apart many accesses: search engines and crawlers,
older phones and mobile devices, etc. Since you can already run PHP code
in your server, why don't you simply increment the counter when you
deliver the page, rather than waiting the browser to report back?
Possibilities:
- Add PHP to your HTML file and instruct the server to process it
through the PHP interpreter.
- Write a PHP script the delivers the HTML file.
- If using Apache, write a PHP script the delivers the HTML file and
hide it with a mod_rewrite redirection.
And last but not least, find the stats section at your hosting
provider's control panel.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|