Move analytics code to header
Merge branch 'master' into production