Generic API for tracking events