Moved analytics into own file, to tidy up