Move analytics code to header