Google Analytics is my tool of choice for tracking visits to my websites. WordPress is my CMS of choice (at the moment) for powering my websites. Google Analytics and WordPress, therefore, are a good combination for me. This piece explains how to add your Google Analytics code to your WordPress driven website.
Installing Google Analytics In WordPress
In your WordPress control panel in the Appearance section, click Editor.
This takes you to the Edit Themes page. Over on the right, underneath Theme Files, you will see a list of all the templates used to create your website. Different WordPress themes use different templates, although some are common to all themes, so what I see in my list may not be the same as what you see in yours. We need to find the template that has the </body> tag in it so that we can insert our Google Analytics code immediately before it. As the </body> tag appears towards the end of a web page, there is a good chance that it may be found in the template called footer.php. In fact, footer.php contains the </body> tag and the </html> tag so this is the file we need to edit.
WordPress Themes That Handle Your Google Analytics Code