Tracking visitors on private website?

Hello. I have built a private website where people from work can view work-related pictures.

The home page is really just a log in screen. And if you successfully log in, then you can navigate to various photo galleries.

I would like an easy way to track how many people visit my website, and also have some way to differentiate them (e.g. by OP address).

I have used Google in the past to track traffic on a business website, but am not sure it makes sense for this private site. Plus I don’t want to have to spend a bunch of time creating a new Google account, and so on.

Any suggestions on how I k=might track traffic and unique traffic to this private site?

By the way, this is on a web server where I have access to WHM and cPanel, so maybe that is how I track visitors?

How does your log in screen validate the login given to it?

Tracking by IP address is lovely until you get dynamic IP addresses, people using someone else’s device, terminal servers, multiple connections from the same remote site, and so on. As @m_hutley said, you have a login, so use that to track usage.


It’s a pretty wimpy log in screen…

It asks for a username and password. The username represents the client folder I am giving access to (e.g. ACME). Both username and password are hardcoded.

It is a down-and-dirty site to display photos from a party we had.

I know how to build a database -driven login, but don’t want to spend the time. So I was looking for some easy way to get a sense of who comes to check out photos.

True, but for my needs I just wanted an easy way to get a sense of how many checked things out.

Normally, yes, but as I just replied, there is only one set of credentials for everyone. Username = client name and password will be emailed to everyone at work.

You could download and install Matomo. It requires PHP + MySQL.

Installing it takes 10 minutes, configuration is minimal, no sign up is required and the analytics data stays on your server. Make sure to download the free (self-hosted) version though, not the cloud solution.

When the login details are successful, append (on a new line) date/time, username and password to a text file.

How do I create such a log file using PHP?

Would I be able to capture IP address also?

For the IP address:

Try logging in, view the following output and take your pick:

echo '<pre>'; // add line feeds so easier to read
print_r( $_SERVER );
echo '</pre>';


I would also be tempted to use current date(‘y-m-d’) .‘.log’ as a file name and create the file if it does not exist.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.