Hit counter


#1

How would I make a hit counter in HTML? I have researched some, but I've got results that seem old and or that require downloading something which I don't want tot do. Also I'd like the method to be able to work through GitHub.


#2

First question... How does one implement a keep alive variable on the host server? I don't think we can without a DB, the simplest of which would be a CSV file. Not sure how secure it would be.

The page loads and the final element in the page is an img tag with a request for a placeholder GIF or PNG or SVG file, which img is 1px by 1px and 100% transparent. The flagged request is handed off to the counter handler and the data updated, after which the request is handled and the img sent down. Nobody will be aware of the element in the page because no matter where it falls, it's transparent..

We also have server access logs we can look through if we really want to be true to account. There is our honest database. The number of requests for that file will be the count of pages seen and not necessarily of visitors; and, not all visitors come in through the front door.

In other words, hit counters are not a real measure of traffic if hits to other pages can be missed, or the aggregate cannot be adequately analyzed to render a true picture of the traffic flow.


#3

Are there simpler ways like: a variable counter that just adds one every time the page is loaded? This maybe what you're describing, but I'm not sure. Also if you can could you post some example text? Last is the method you described able to be seen by only the website editor?


#4

I just described the simplest ones, though they need special attention.

In a NOSCRIPT environment, the image would be requested and only logged by the server. In a script environment the request could be logged (and handled) in an additional way.

That only deals with the client side. There is still the server side to contend with. A flagged object has been requested which zings by our detector and the existence of that flag is registered. The request details are captured on the fly and it goes on its merry way to completion. Meanwhile the server-side handler is logging any captured data to a txt file.

The key is in capturing necessary data, such as page and object requests (transparent GIF, PDF, links followed, etc.). This is not an easy task but if you can make it happen? Doors are going to open for you.


If you really want to get a visitor count then track a consumable. A PDF is one way to track. Especially if it is something users have come to expect, and they recommend it to their friends. Keep that PDF consumable and regular and the numbers will keep going up. When they level off, you know it's time for a change.