server/api: little refactoring
client: move the analytics code to head