refactor analytics events and page tracking