Just so you know there's about a week's worth of replies in your 3 paragraphs.
For a start there's a difference in kind between a static website and one that is dynamically served. Roughly, a static website has its design and content locked in and hard coded, a dynamically populated one has a database with pieces of information in it which are retrieved and put into a page for display when given a request. The way that information is then visually presented can be altered without affecting the actual content (eg. my text is now coloured blue, but the words are the same). It gets a little confusing because some CMS allow you to input HTML or code that will affect the display, but the main distinction is where the content for your website is located.
The theme's in use by CMS's alter the display properties, typically the default theme's installed with a CMS do exactly that. But other themes can become quite complex by building in shortcodes and all sorts of extra function's that the CMS may not contain natively. Again this is how it can get confusing, it is called a theme but it may contain plugins as well.
Converting a static website to a dynamic one I would suggest represents a different way of operating, and you may find that lifting the content out first and then styling it is actually a faster route (though it may represent some 'wasted' effort on your part if you have everything working perfectly already).
As for the google codes etc, CMS's have a series of files that allow you to insert your content and code into different parts of the page easily. Typically there will be a place where you can drop in a google code in the main settings for the CMS, and it will then be served as part of every page on the website.
There are some website services that will convert your website to a custom theme if you have a stable and consistent design structure throughout your website. I've never used them but I see them advertised so it may be an option for you.