How to Add a Live View Counter to WordPress


👉 Divi Builder drag/drop page builder for WordPress

I don’t know about you but I always use a live counter to see how my site is growing. It is not as helpful as Google Analytics but you will be able to get a quick reading. There are plenty of plugins and sites that offer widgets you can add to your site to track your visitors. You can always write your own code though.

This is a lightweight code you can add to your functions file to display a live counter to your site. It updates every 5 seconds not to put too much load on your server. Here is how it works: when you get a new visitor, action=heartbeat is pinged. Your server will store IP and timestamp in a 45-sec transient. The # of IPs seen in the last 30 secs are returned with an Ajax call and shown.

More WordPress reading: