I'm not an expert with jQuery, but I think something like this might do the
trick..
$("a.adtrack").click(function(){
// Get url of advert
var adURL = $(this).attr("href");
// Log click to database
$.ajax({
type: "GET",
url: "/path/to/tracking/script.asp",
data: "advertURL=" + adURL;
});
// Redirect to target URL
window.location = adURL;
});
Give your links a class of "adtrack"....
<a href="http://www.someurl.com/" class="adtrack">Go to Some URL</a>
Then you can go about setting up your tracking script to request the URL
from the querystring and log it to the database.
--------------------------------------------------
From: "Darren Savery" <[EMAIL PROTECTED]>
Sent: Tuesday, December 11, 2007 4:50 PM
To: "jQuery (English)" <jquery-en@googlegroups.com>
Subject: [jQuery] Using jQuery to track advert clicks
Hi,
Is it possible to use jQuery to track advert clicks? I have adverts
that appear on certain pages of my site. Whenever someone clicks on an
advert, I would like to record this as a new entry in a database table
(tblAdvertClicks).
I know I could pass the visitor to a processing page then forward them
on to the advert destination, but I want the link to do directly from
my site to the advertisers - without a 3rd page being involved (this
is for SEO purposes in case anyone is interested). Someone suggested
jQuery could do this.
Can anyone help?