Click to See Complete Forum and Search --> : Keeping track of image clicks


bryce
10-12-2007, 01:36 AM
Hi everyone,

I am currently designing a website in HTML, and would like to know how I can keep track of how many times a image is clicked on. Note that when the image is clicked on, it links to another external website.

There's more though. Once the image is clicked on and the number is recorded, I need below that image for the total number of clicks, of that exact image, to be shown.

Anyone know what I need to do?



-----
Bryce

patudzu
10-12-2007, 03:43 AM
Tell what do you need to about refreshes.

There is an option that is to include the image.

<img onclick="window.open ?imageid=xxx
a webpage where you "increase the visit counter of the id image" and then redirect to the other site

The next time the user refreshes the original page with the image, it will have the correct count number.

If you want the correct number right after click without any refresh you can make
<a href="other site" onclick="IncreaseCounter(imageid);"
IncreaseCounter() can increment the image counter but the next time the pages refreshes there will be no record about the "new" image index.

So... to the server knows that someone clicked on it I would suggest to use xml http request object and you can make the IncreaseCounter to communicate with server side and write the new index of the image on database.

What do you think about all this? :)

bryce
10-12-2007, 03:56 AM
haha wow that is quite an answer. But, I'm kind of new to this all. I know my basic html and layout, and a little bit of php and css, but this I'm really confused about.

Could you word it out for an inexperieced guy? :) I kind of understood what you meant with the stat counter, but where what stat counter should I use? And I got lost when you said about the serverside stuff. The first option sounded good though, I don't care if it doesn't display the added count straight away (unless there is way you can do this with it working smoothly).

Bryce

patudzu
10-12-2007, 04:37 AM
So the best way for now is not to display the added count straight away. You can implement in the future.

test1.htm
<HTML>
<body>
<a href="test2.php" target="_blank"><img src="http://img210.imageshack.us/img210/1832/taca4bh6.jpg" border=0></a>
<br>
10
</body>
</html>
test2.php
<?php
// Increase the counter in the database
?>
<html>
<head>
<title>Redirect to the right page
</title>
<META http-equiv="refresh" content="0;URL=http://24onthespot.com/"></head>
<body bgcolor="#ffffff">
<center>You will be redirected...</center>
</body>
</html>

bryce
10-12-2007, 06:51 AM
I've just set up the two documents you wrote, and it's not really working. When I added the php to test2.php, it just displayed as text (the entire code). And the redirect doesn't work. Also, I'm not sure where the counter is meant to be.

Sorry if I'm annoying you :p. Maybe you have msn, aim or something?

my msn is: bryce_111(at)hotmail(dot)com
and aim is: monkeytech1

Speak soon. :)

bryce
10-12-2007, 06:54 AM
I got the redirect working, but I'm not sure where the stat counter goes.

patudzu
10-12-2007, 08:43 AM
hi m8.
you're not bothering at all.

post on my board http://codersboard.com (http://codersboard.com/) your url so I can help you better.

it's easy to make it working.