You might want to read
this blogpost by Liza Daly. Tracking software is basically just a piece of script embedded in the page, so you might be able to modify it to suit your needs.
This would probably
only work on iBooks, though, I don't think there are other repub readers that recognise Javascript.