How to Add Visitor Counter to Website in PHP
1

How to Add Visitor Counter to Website in PHP

Would you like to see how many hits your website or webpage have?

Yes! I also wonder to see as well.

I have demo directory where I upload my portfolio type work to showcase. Very recently uploaded a pricing table built for a Genesis Framework project. Share on bookmarking sites and I got 2067 hits. So, let’s get the ball rolling to see how I added visitor counter PHP script on my page.

Add Visitor Counter to Website in PHP

We will need two files. One for the script and another for hits storage. Here is a screenshot of my directory. Sharing, so, you get the things easily.

Directory-Shot-Add-visitor-counter

Step 1: Create a file, named counter.php. Edit it with Notepad/Notepad ++

 

Save the file and upload it to the directory.

Step 2: Create another file, named counter.txt. Upload this file to the directory. You can put any number in this file it will echo as log where you want to show the page hits.

Step 3: You see the index.php file to that directory in the screenshot above. That the file where I am going to include the counter script. So we can see the “Number of visitors to that page”.

Visitor-Counter-to-Pricing-Table-Page

I simply wanted to add visitor counter at the footer. So I added the below snippet under of all elements.

 

Conclusion

We have reached the end. To give your page a decent hits open counter.txt file add value/number and save it. That’s all! If you face any restriction, don’t hesitate to add your comment below.

Editorial Staff
 

Editorial Staff is an in-house team of native WordPress developer and industry columnists.

  • Alluna says:

    Thank you for posting. That may be helpful.

  • >