If you want to install your Wordpress script so that it works regardless of the theme you install you will need to paste your code into the general-template.php file in the wp-includes folder. Here are the steps
1. In your Wordpress installation go into wp-includes
at the bottom of the function (around line 68) before the closing "}" put a " ?>" . . . At that point paste in your Google analytics script (This is the script that you would get after registering your site at Google.com/analytics. Paste The code then put "<?php" . Save your file - Delete the cache of Wordpress and everything should be working.
What we've done is install the Google Analytics script into the get-footer function. That way anytime that function is called (i.e. the end of the wordpress template action) the analytics script will be drawn. That will ensure that whatever template you are using the script will work - eliminating the need to put the script into any actual template code.
*This will only work if the template you are using calls the get-footer function.
** IF YOU UPGRADE WORDPRESS YOUR CODE WILL DISAPPEAR AND YOU WILL NEED TO REPEAT THIS PROCESS. When you do an upgrade the Wordpress core files are replaced with the newest version of the CMS - this will remove any custom code you made.