PDA

View Full Version : adding a simple counter to a site.


cb911
Nov 7, 2003, 02:21 AM
i'm just wondering if it's possible to add a counter to my site that just tells me how many people have visited?

i don't want to actually display it on my site, that would just be lame. :p but is there any way i can collect data of how many people have visited my site, then view the data later?

even better would be being able to collect data like what browser people were using when they visited my site. and how long they stayed for. it would be useful to have statistics like that available.

i'm guessin that all of that sort of stuff would be done through cookies?

but my first priority is just to get a simple couter going. so any help with that is greatly appreciated. :)

carrington
Nov 7, 2003, 11:12 PM
There are lots of free counters available. They typically involve using a remote graphic on your site. Every time somebody loads the page, the graphic shown looks like a higher number. The advantage is that this is easy to do and doesn't usually require any "higher" technology such as PHP so it'll work on even free (and by free I mean crappy) web hosts. The disadvantages are many, including a (usually notable) slowdown of your site as it waits to load the remote graphic.

Plus there's nothing like a counter to let your viewers know your site is unpopular, which can drive away traffic like nobody's business. ;-)

If you do want to use such a counter anyway, just Google for "free web counter" and you'll be offered hundreds of choices.

Any decent web host is going to include statistics for your site, though, so a counter should be unnecessary. At the very least, you should be able to have daily traffic logs generated: these are just text files which list your "hits." You can parse your log files with a logfile analyzer, such as analog (http://www.analog.cx/). And yes, using logs means you can find out information about your visitors including browser use, etc.

cb911
Nov 11, 2003, 03:48 PM
thanks. i just checked that my host does provide the stats i was looking for.

now i've just got a question about them. i'm wondering what the referer is? i'm guessing that that's how a person got to my site, by a link on the page listed as 'referer'?

also, i'm wondering what exactly 'hotlinking' is? is that like where someone links directly to a movie on my site, then lists that link somewhere?

thanks for the help. :)

carrington
Nov 11, 2003, 11:25 PM
Yes, the referer (single "r") is the URI from which the browser was directed to your site. For instance, if I'm on a page (A) and I click on a link to a page (B) on your site, then the referer for that move was the URI for page A.

Note that the referer will not always be available. Sometimes there isn't one, such as when a person uses a bookmark or types the URL manually. And browsers can be set up to not pass along referer information, such as for privacy reasons. Some firewalls automatically strip referer IDs, too.

Hotlinking, or hyperlinking, or linking, and so forth, are all the same thing: depending on context, it either means the act of clicking on a link from one URI to another, or it means the act of placing a link on a web page. The latter is the more typical sense, as in "I hotlinked to your site" which would mean "I have placed the HTML code for a hypertext link to your site on one of the pages of my own site."

cb911
Nov 12, 2003, 01:25 AM
thanks carrington.

so linking is all the same.... but hotlinking is usually talked about in a bad way.

normal linking is where someone lists you on their site, then that just brings you to the front page of your site, right?

so as i understand it, hotlinking is where someone links directly to content on your site, like a video or something. is that correct?

mnkeybsness
Nov 12, 2003, 09:34 AM
Originally posted by cb911
so as i understand it, hotlinking is where someone links directly to content on your site, like a video or something. is that correct?

you got it. any time a different site is using your bandwidth, they are most definately hotlinking a file, usually images or videos. sometimes that's okay, but usually not acceptable.

cb911
Nov 14, 2003, 04:08 AM
thanks mnkeybsness. i'll be sure to look out for that sort of thing.

brianellisrules
Nov 14, 2003, 03:51 PM
so how do you prevent hot-linking? I know some sites have alternate "don't steal our bandwidth" type of graphics when someone tries to hot-link their site.... how does one go about implementing something like that?

mnkeybsness
Nov 14, 2003, 05:04 PM
that's a good question... i would like to know the answer also

it must have something to do with the server it's being run on. that's my guess

Makosuke
Nov 14, 2003, 06:24 PM
Originally posted by ber.com
so how do you prevent hot-linking? I know some sites have alternate "don't steal our bandwidth" type of graphics when someone tries to hot-link their site.... how does one go about implementing something like that? It's not a trivial thing; there are a number of things people try, but all of them either don't work very well, run the risk of blocking legitimate users (Keenspace has problems with this), or both.

One solution is to have a small CGI or PHP script that obscures the actual location of download files and essentially feeds the download to a person on request. It can also refuse to do so if the link didn't come from the site it's supposed to. In my experience, these just don't work very well, although I suppose they could. They're not really an option with embedded content, either.

Another way is to restrict access to some content so that it only accepts links that come from a certain domain(s), using an Apache feature called an .htaccess file (you may have already played around with one).

This method is somewhat more reliable, but you still have major issues if somebody has their browser configured not to tell you where they came from (security-minded folks), or they're behind some types of firewalls that block that information for security reasons.

In some cases, these can also be defeated by just reloading the bum image (whatever Angelfire uses, for example, can be worked around that way).

Nothing is foolproof, so the issue in the end is how much hassle it's worth to you, and what your acceptable tradeoff between blocking "thieves" and accidentally annoying legit users is.

cb911
Nov 14, 2003, 08:08 PM
on the control panel of the server that i'm hosted on it's got an option for hotlinking protection. you just have to type the specific URL's that it will allow access to. for example, you have to specifically type http://domain.com as well as http://www.domain.com. then those are the only URL's that it will allow to link to your site. i'm not sure how well it works though, but it seems like a simple, effective solution.

one other thing, you can also have a list of protected extensions. for example if you list jpg,jpeg,gif,png,bmp other sites won't be able to link to files with those extensions.