it should work if you copy and paste the complete code under the footer area before the </body> tag. Also make sure the analytics code is not included in the <?php ?> tag.
I agree with previous post .... put all code before closing body tag </body> and be sure that u put it all in footer zone .... after that all should be fine