How Do I Count the Hits on My Website?
A hit counter on your website tells you how many people are visiting your site. Knowing how many people are coming to your page can show you your growth over time and can be a statistical starting point for how you tweak or modify your site. Counting the hits on your site can be simple or slightly challenging, depending on your need and level of technical expertise. There are many free website hit counters you can find on the Internet, or you can make your own and customize it as you see fit.
Instructions
-
-
1
Create a blank text file. You can name it anything you like, but something familiar like "pagehits.txt" is easily recognizable. Leave this file blank.
-
2
Choose the page for which you want to count hits. A good place to start would be your main page, usually called "index" plus a file extension. If you want to count hits on several pages, you will have to insert your code into each page.
-
-
3
Open the page file for which you want to count hits in a text editor. At or near the top of the file is where you should put your hit-counting code.
-
4
Enter the code in the file. The code should include commands to open your "pagehits.txt" file, update the number in that file by adding one to the running tally and closing that file again. This code will be accessed every time someone visits the page.
-
5
Repeat steps 2 through 4 for any other pages for which you want to track codes. If you want to use the same "pagehits.txt" file to count hits for unique pages, have the hit-count number for each page be associated with a unique keyword in the file. In your web page files, have each page search the "pagehits.txt" file for the unique keyword chosen for that page, then have the page assign the associated hit-count total with a variable.
-
6
Save all files and upload them to your server.
-
1
Tips & Warnings
You can choose whether or not you want to display your hit total on your web page. Most professional websites do not display the totals on their pages and choose to use the number as internal data.
If you choose to hide your hit count, you can access the number yourself by opening the "pagehits.txt" file and checking the number, or you can create another page file that is not made public and have code in that page access the hit count total with a "read" command.
If you do not want to create your own hit-count total, there are hundreds of free options available on the web that you can choose from to incorporate into your web site. Google Analytics has a number of page tracking features and is by far the leader in the industry.
It is easy to accidentally change the number in a "pagehits.txt" file, creating errant data. This is also not a reliable source of information if you need to present your hit count as anything other than bragging rights to friends.
References
Resources
- Photo Credit computer image by Ewe Degiampietro from Fotolia.com