Refactor action tracking to implement analytics events