Google advises putting the google analytics script right before closing the .
However, I would prefer to combine it with the rest my javascript
I had the script in body section just before ending body tag and it was always showing that my site is missing tracking code analytics admin panel so I moved to head section and it works fine.