Moving analytics code to head