Tidy up insertion of analytics code