Moving analytics code to header