The link you provide in ur site for advertisement will have a extensions which provide information abt ur site.So they can determine where the link was originated.And they will have count stored in their database.
If you wanna store the click counts in ur db,u can do it with url extensions.Just add the advt link with ur url and send to a
servlet or
jsp page.So there can u can retrieve click counts and add details to ur db.
---
basha