Google analytics code refactor