How to Track Website Visits Without Google Analytics — A Lightweight and Independent Approach
In the age of advanced analytics tools like Google Analytics 4, many website creators notice that the data can be unintuitive, delayed, or even contradictory. That’s why, if you prefer simple, local visit tracking — without external scripts, cookies, or Google’s privacy policy — it’s worth implementing your own IP logging system. This gives you full control over your site’s traffic.
🧩 Why not Google Analytics?
- Report delays — GA4 processes data with several hours of delay, making real-time analysis difficult.
- Bot and user filtering — some visits are automatically excluded, which can lead to underreported statistics.
- Complex session definitions — not every visit is counted as a “session,” leading to confusion.
- Lack of full control — Google stores data on its servers, and you have no influence over its availability or interpretation.
🛠️ Simple script for logging visitor IPs
Just a few lines of PHP are enough to save visitor IP addresses to a local text file, organized by date. This lets you analyze traffic without relying on external tools.
function log_user_ip_by_date() {
$user_ip = $_SERVER['REMOTE_ADDR'];
$today = date('d.m.y');
$log_file = get_template_directory() . '/ip_log.txt';
$log_content = file_exists($log_file) ? file_get_contents($log_file) : '';
$entry = $user_ip . "\n";
if (strpos($log_content, $today) === false) {
$entry = "\n" . $today . "\n" . $entry;
}
file_put_contents($log_file, $entry, FILE_APPEND | LOCK_EX);
}
add_action('wp_footer', 'log_user_ip_by_date');
📁 Result in ipLog.txt:
19.07.25
36.214.0.216
52.167.144.176
207.46.13.92
🔍 What does this system offer?
- Full control — data stays with you, without intermediaries or external servers.
- Instant logging — the script records each visit in real time.
- Analysis capability — you can easily identify which IPs belong to bots and which to real users.
- No cookies or external scripts — ideal for minimalist and privacy-focused websites.
🧠 Extensions and ideas
If you want to expand the system, you can:
- filter bots by
User-Agentto log only real users, - log only unique IPs per day to reduce file size,
- add visit timestamps to track activity throughout the day,
- generate charts from the data (e.g., via CSV and Chart.js) for easier visualization,
- create separate log files per day for better data organization.
🧭 Summary
Not every website needs advanced analytics. Sometimes a simple, local system is enough to ensure clarity and independence. If your site is just starting out, this script is a great way to monitor traffic without unnecessary complexity. What’s more, you don’t have to rely on external services — you’re fully in control.