anywhere within head tags is fine, but google recommends to put it the last just before the head closing tah
If you using the newer version "Asynchronous Analytics" tracking code, you should put it right under open <body> tag. If you using older version, its better to put it right above closing </body> tag. Putting JS script in head tag may reduce page load performance. As the javascript needs to be downloaded before any part of your site will show. But for the newer version, the performance impact is minimum.
you can put GA code before </head> its not mandatory to put code just before head section. you can put in between scripts
For the older one Google recommends - just before </body> For the newer one i.e. asynchronous code Google recommends - just before </head>
I keep my codes in the body, though I've actually put them in the footer before and they worked just fine. If you don't want to risk it, keep it in the body.
Copy your Google Analytics code from your GA account then paste into your site footer section. after that verify your code.