moved analytics code to correct location