Jump to content

How to create page views for every pages?


SandySynaptik

Recommended Posts

Whenever the page is viewed, you need to insert the user's IP ($_SERVER['REMOTE_ADDR']) and the name of the page into the database. Then you can find out how many unique visitors you've had with this SQL query:

SELECT COUNT(DISTINCT ip) FROM visitors WHERE page = '/pagename.php'

On my website, I've gone further and also logged the user's browser ($_SERVER['USER_AGENT']), referrer (the page they came from, $_SERVER['HTTP_REFERER'] (sic)), and location. You can do these things with Google Analytics, but I wanted to figure out how to do it with PHP.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...