views:

78

answers:

2

I'm using Shadowbox.js to display a slideshow on a website. This slideshow shows several pictures and I would like to know who's looking at what pictures. For this purpose I'm using statcounter.com. Shadowbox offers a so called hook to call a function when the slideshow opens and when it changes to another picture. I've written a small piece of code to get things moving, but for some reason, I get an entry in my statcounter log, but the shadowbox does not appear. When I don't use the onopen and onchange in the options, the shadowbox does display. As a test you can set up a directory where you place below code. Create to subdirs in this directory called "sb" and "pix". Get the Shadowbox-application from the website and store it in the "sb" directory (http://shadowbox-js.com/download.html). Next to that store 3 testimages (called image1.jpg, image2.jpg and image3.jpg) in the "pix" directory. To check if statcounter is picking up the pictures, you can use my testaccount on statcounter.com (just for viewing: account testcase, password casetest1).

Please find the html with the code here: http://www.heres-online.nl/test/index.html

Please take into account, I only just starting in javascript and html programming. I can imagine I'm overlooking something terribly simple ... Any help is highly appreciated.

+1  A: 
Pointy
Wow, that's a fast answer. OK, the way you propose to get rid of a lot of garbage in my function is really a good idea. As I said, I'm pretty new to javascript and html, so your suggestions are more then welcome. ;-)However, adapting my source with your suggested lines, still doesn't bring me a working shadowbox slideshow AND a statcountertraceline per picture in the slideshow. Any suggestions how to solve that?
Jake H.
Well, what is going on now? Oh oh wait - here's one thing to try; it could be that your browser thinks the image is in the cache - I'll update my post.
Pointy
OK I slightly changed the function. Now, if you still have problems, I suggest installing the "TamperData" plugin (or something like it) for Firefox. That will let you track all the HTTP requests your browser is making. For you, that'll mean the ability to see if that tracker stuff is really resulting in an HTTP "get" to the counter URL. (I think it will, but I'm not really set up to test that.)
Pointy
I've uploaded the output of tamperdata when clicking on the image in image1 on http://www.heres-online.nl/test/index.html
Jake H.
Hmm well it looks like it's getting at least *one* statcounter thingy. I'll look at your page again.
Pointy
Every time I click on that (and it took me a while to figure out that the TamperData screencap was actually the new test image :-) I definitely see a statcounter go. Hold on a sec - do you want to *see* something from statcounter? If so then I misunderstood. I'll add a little more to my answer!! Sorry about that.
Pointy
No, in fact the idea is people are viewing the images in the shadowbox application, and for every picture they see, the onopen/onchange hook in shadowbox should register this via the tracker function on statcounter.com. So I don't wanna see the statcounter stuff at all, but that stuff should happen in the background at the same time.Can you still make sense of my lines? ;-)
Jake H.
Maybe you can view this first: that's the original shadowbox presentation, without the onchange and onopen in the options variable for shadowbox. That's what I still want to see (and only want to see). In the background every picture viewed should be registered with a line in statcounter showing the picturenumber and the date/time/etc-specifics.http://www.heres-online.nl/test/index_sb.html
Jake H.
Well OK hmm. Well I don't know what that "Shadowbox" thing is supposed to do, but I'll check. Clearly it's working at least partially, as the "click" handler is definitely firing.
Pointy
I'm appreciating your (and any) help a lot Pointy! Actually, I didn't count on getting an answer this fast at all. Nice!
Jake H.
As I'm living in The Netherlands, the clock is telling me its 00:45 CET now. My bed is calling as the buzzer goes off in say 5 hours :-( ... I'll check on my post later on. Thanks for all your help sofar.
Jake H.
OK - yes when there are good, fun questions on Stackoverflow, you may get answers *very* quickly - I will look at the script
Pointy
Good morning. I'll update my script with what I figured out. Basically there were 2 problems: first, the function (tracker1) apparently has to return `true` or else the "Shadowbox" thing decides to stop working. Second, I had picked the wrong function name when setting up that statcounter URL.
Pointy
Good morning to you too (or whatever time it is on your end) ;-)I updated the index.html on my end with your last modification, but apparently nothing is happening now. I see the first picture but when I click it, it seems like the tracker1 isn't called for some reason.
Jake H.
A: 

Hi Pointy. Please hold your horses on my last comment. I made a mistake myself (typo). Instead of encodeURIComponent I typed enocdeURIComponent (why not copy/paste ... yeah, well I just didn't). The script is now doing exactly what I intended it to do. I know have a Statcounter entry for every picture in the slideshow! Superb. I'm very pleased with your help, this was really nagging me, not being able to get it running. And the speed of getting an answer here was really amazing! I've posted your solution on the Shadowbox.js forum as well. I posted my question there too, but no answers yet. But for anyone strugling with the same issue, this solution might be helpfull. Thanks again, and have a nice weekend!

Jake-H