move analytics to the head and switch to async