Jump to content

Question for webpage gurus: Hit trackers/counters


Lt Bull

Recommended Posts

Hello

I want to know if it is possible to track how many times a file hosted on the webspace my ISP has provide me with, gets downloaded/accessed by users.

There is no/I have no webpage at all. It is really just a URL link to a file located on my own webspace.

Also curious about the "normal" way in which hits on a URL on a webpage are tracked. Lets assume that someone has a webpage with a link on it to a file. I can imagine that if you go to that page and click on the link to the file from that webpage then I can see how a counter on that webpage might track the hit. However, if I open up a browser and simply type in thw URL to that file, does this hit bypass that counter that is meant to track the number of downloads?

Cheers

Bull

Link to comment
Share on other sites

Is your webpage going to run on a dynamic server capable of running scripts or just a basic host server?

I don't know the answer to that question but I do not "own" the webpage from where the URL is located. I have no "front end" webpage that users need to access to click on the URL, just a URL that gets posted soemwhere.

eg. if I decided to place a URL link in this post to a file at my own personal webspace, is there a way I can track how many times people accessed the file?

Another question that will broaden my understanding for what can/can't be done: Lets say that I had a JPG file and I used the Insert Image function in the post editor to point to a JPG file on my webspace. In theory everytime someone viewed this post they would effectively download the file from my webspace. Could the number of times that image file was accessed like that be tracked?

Link to comment
Share on other sites

Do you have access to the server logs for your webspace? If you do, all your tracking wishes can be fulfilled. Most hosting plans also come with some kind of log analyzer / stats software, so you don't actually have to look at the raw log files.

This sounds promising! But unfortunately I don't know the answer to that question either. Short of asking my ISP directly, is there a way I can tell by looking at the contents of my webspace?

Though I did basically ask them if what I am asking here and they replied "Unfortunately, we do not have access as such to alter your web space to add a counter for hits/downloads. However, this web space is yours, so if you can write or find a script for a download counter, you are more than welcome to upload this to your web space."

Link to comment
Share on other sites

Well, that would be the alternative: generating the data yourself by including a script into your front page (as documented in the link Wicky provided).

You're saying you don't have a front page, but you could probably make one very easily. Try this: take any simple html-file, rename it to index.html and stick it into your webspace. Try to access it from your browser, work from there...

Link to comment
Share on other sites

I see. Is there something specific about naming it index.html as opposed to anything else? Is the the name index a reserved name that give it specical properties as far as HTML coding goes? Does an index.html file in a webspace directory "own"/manage/monitor all network traffic to and from that directory and all it's subdiredtories?

Would it still be able to count the downloads if no one ever accessed that index.html page (except myself to view the counter) but just clicked on URLs posted elsewhere to download the file?

What I havent understood yet is how a html file (with a counter script) that just happens to reside in the same directory as a hosted file is supposed to know whether a hosted file in that same directory gets accessed via an exteral URL.

Apologies for my retarded knowledge in these matters.

Link to comment
Share on other sites

The easier route by far would be the server logs. The server knows which files it serves, and it doesn't care where the requests come from. Ask your ISP.

There is nothing special about index.html. It is just by convention the "root" file for a website which shows up when no specific file is requested, and it doesn't in itself do any tracking. (You used to get just a list of all files in the directory if index.html didn't exist, but providers tend to disable this by default these days).

A script embedded there wouldn't track any external requests for specific files. The idea would be to direct all traffic to the index file, but it doesn't prohibit anyone from requesting stuff directly. (Prohibiting could be done, though, of course).

I can only encourage you to read up a bit on html and basic web design, it's really not rocket science.

Link to comment
Share on other sites

All webservers would be server-side script enabled, from either .net/ASP to .php or others. As mentioned, the most *reliable* method would be to use a log analyzer as provided by your ISP. This is typically standard stuff that is included with a decent hosting package, however it may not be included in a freebie hosting account that you get for having someone as an ISP. You'll just have to ask or search their website to see if/how you can enable that. A web-log analyzer can/will track not only what pages were requested and by whom (via IP address), but also what on a page was requested - from images to links clicked (i.e., files requested). This is probably what you want.

A javascript (client-side script) hit counter (one of the cheesy numbers on a page looking things) are *very* inaccurate in that if the same person returns to the page a dozen times -or- is on the page and simply hits refresh, the counter is going to rack up a hit whether or not he downloaded the file. That may or may not be what you want recorded. I realize that yours probably isn't a business site, but I tell clients that ask about those types of hit counters "it not only tells you how many times that your site has been accessed, it tells everyone else how many times it hasn't been". They look very unprofessional.

If you want to tinker around with one though, Bravenet has a free hit-counter (and many other free tools), see LINK. I have seen javascript hit counters that don't show on the page - hittail.com was one, however you had to pay for that service.

Edit to add: ALL webservers are also going to have web logs running that are tracking all of this stuff (though some things may be disabled, depends on the config settings). Whether or not you get to have access to those web-logs depends on the host - they generally need software that takes all these raw log files and makes the pretty pictures and graphs specific for each virtual host/directory (i.e., your website) that is on the server.

On the index.html thing, it all depends on what your webhost has mapped for each home directory, it could be index.html, index.htm, default.html, default.htm, index.php (if PHP is running on the box) or it could be ALL of those (amongst others). The reason that you don't have to type www.mywebsite.com/index.html is because in this case (and generally), index.html is mapped by the server to be the root page of the home directory - i.e., it defaults to that page. So that is going to be the page that will always come up if someone just goes to www.mywebsite.com so would generally be the page for a client-side hit counter if you were to count (inaccurately however) ALL the visitors to your website. If you're trying to monitor the download of a specific file on any one page of your site (that is or is not your "home page") then this instruction about "index.html" is irrelevant - you need the client-side hit counter on whatever page it is that you have the link to the file that you are offering for download.

Another alternative is to use client-side script (which I forgot to go into). But that is going to be way beyond your scope here unless you quickly pick up basic HTML and then find out what server-side scripting is offered with your hosting and then quickly pick up on how to write/add such code to your page.

I'm curious, why the need to track this information - is it just to satisfy your own curiousity or is there a business need?

Link to comment
Share on other sites

Thanks for the tips. :)

GJK, this is not for a business need, but to just check the traffic to some files I have on my webspace.

I have contacted my ISP and it seems my webspace is just one of those freebie ones where I don't have the server side control. The help desk guy however did send me a link to this site http://www.totallyphp.co.uk/scripts/text_file_hit_counter.htm saying that if I place this php script file in my webspace I could get it to count access to a file on my webspace. I tried clicking on the download link for the script however and all it did was load up another page so i don't know if that will work or not.

Is this kind of what you were suggesting as far as using a client-side script?

Alternatively, I know that instead of just dumping my files in my webspace without any webpage (html) and providing users with the direct link to download the files, I could instead direct them to a html file on my webspace which has links to the files and a hit counter embedded to in thw html to could the clicks on the links. However, I am still curious to know the way to track the number of direct hits the file that bypass any hit to the html page.

Link to comment
Share on other sites

That script on totallyphp.co.uk is a SERVER-side script (PHP), so that code would need to be added to the page that has the link(s) to the file(s) that you are offering. I too tried to click to download that script and it led to another page with no download link, but I think that I found an alternate download location HERE.

The other solution is the CLIENT-side script (javascript) - one is provided at that Bravenet.com link that I gave earlier. Frankly, that would be easier to set up and is about the same on accuracy (ie. if they sit and hit "refresh", it will continue to rack up the hits whether or not they actually downloaded the file).

If you want absolute accurate control over how many times the file was actually accessed, you will need to write your own custom SERVER-side script. That is what I did for www.the-proving-grounds.com and www.the-scenario-depot.com so that I could track how many times a scenario file was downloaded (you may have the same thing in the works? :) ).

Link to comment
Share on other sites

GJK, that alternate link you posted doesn't seem to work.

The ISP help desk guy (not sure how practically clued up he is on all this) basically told me that all I had to do was dump that php script file in to my webspace folder (where the file is) and (once you set it up) will track the hits/downloads to that file directly, without the need for there to be webpage in which it is embdedd or through which users would need to access.

You say that I would instead need to add it to the webpage that was offering the link. Was he mistaken?

So can I achieve what I want to do without first directing users to a webpage html interface that has the link to the files and a counter embedded? Or is it that I basically MUST first direct users to a webpage if I want to count the downlaods?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...