Putting a hit counter (page counter) on a web page helps you track how many visitors visit your web page. There are several ways to go about putting a counter on your page, either by adding a pre-built one or creating your own.

Adding a pre-built counter

If you prefer to add a pre-built counter to your web page, here are a few ways to do so.

We highly recommend using the Google’s Analytics service over any web page counter, as it gives you more valuable information.

  • Check with the web host for your web page. Often the company hosting your web page offer free solutions and provide instructions on how to add the counter code to your web page.

  • You can get a pre-built counter from websites that offer free counters, and add it to your web page with only a few lines of code. We recommend the following sites for free counters.

  • Free counter stat

  • Open a search for more free counter solutions.

Example of the free counter stat

Create a counter

To create a counter, you need to create a Perl, PHP, or another script. Then, you need to either refer to that script through a server-side include or another method. We recommend you already know or learn Perl or PHP programming to create the counter script.

A counter like the one used above increases in count if you or any visitor refreshes their browser. For example, if you refresh this page, the above counter would increase. If other people have visited since you first loaded the page, the counter may go up by several numbers.

The code for creating a counter can vary, depending on the programming language used and the type of counter you want to add to your web page. Below are some web pages that offer sample counter script code, which you can use as a guide to creating a counter.

  • Sample Perl counter script #1
  • Sample PHP counter script #2

We have not tested the sample counter scripts provided on these web pages, so we cannot guarantee they’re bug-free.

  • How to get more traffic or people to visit my website.
  • See the traffic and hit for further information about these terms and related links.
  • HTML and web design help and support.