CPAN has a
MIDI module that you can use to make sound on your computer's sound card. As far as figuring out when a user clicks on a link on a website, you can just update/increment some database field for that and run the MIDI.
Celebrate Intellectual Diversity