Forum Moderators: DixonJones

Message Too Old, No Replies

Way to track banner clicks on ASP pages?

         

dickbaker

9:41 pm on Jul 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've done some searching for scripts to track clicks on a link, but all of them seem to be for servers that aren't running MS SQL server.

I have many ASP pages, and have a potential advertiser who wants to put banner ads on some of those pages.

I'm hesitant to add more ASP code to the pages, just because of the added code to content ratio (my pages are doing very well on the SE's).

Does anyone know of a simple ASP or even Javascript function that would enable me to count the clicks on the banner ads?

Thanks in advance for any replies.

larryn

10:05 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



Dick,

Have you tried using an 'onClick' javascript method in your a tags? That usually works pretty well execpt for people who do not have (enabled) javascript.

Larry

dickbaker

9:27 pm on Jul 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, Larry. I've been playing around with it, but can't get it to work.

Do you know of a site that would have an example?

This is what I've cobbled together right now, which obviously doesn't do the trick:

<p align="center"><a href="javascript:;" onClick="dim sqlsql = "Update dbo.classifieds set clicks =(" & Recordset1("clicks") & " + 1) where id= '128' ">
</a><img src="minibolt_large.jpg" width="500" height="154"></p>

I have all the SQL for the database at the beginning of the page code.

Thanks for any replies.

larryn

11:04 pm on Jul 8, 2005 (gmt 0)

10+ Year Member



Dick,

It looks like you are using VB in your onClick event - which I think expects Javascript. More important is to remember, the onClick is happening on the clients computer in their browser, not on your server. So instead of updating the database in your onClick event, you'll want the onClick event to call a harmless (should return nothing - '204 No Content') script, and that script on your server would update the database.

so it would look something like this (but I'm doing this from memory, so it might not be exactly right):

<a href="someplace.else" onClick="return logit('this link id');">Clickme</a>

<script language="JavaScript">
function logit( logwhat ) {
document.location = "/mycgi/logscript.cgi?id=" + logwhat;
return true;
}
</script>

Your logscript.cgi would then update the database, but at the top of the script be sure to return the No Content header and nothing else, and don't forget to flush out the buffer to the client. Then go ahead and update your DB, no need to keep the client's computer waiting while you do your update.

Hope that helps, feel free to ask more,

Larry